@@ -38,6 +38,21 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38
38
"tmp.zig:2:20: error: TypeInfo.Enum.tag_type must be an integer type, not 'bool'" ,
39
39
});
40
40
41
+ cases .add ("field access of opaque type" ,
42
+ \\const MyType = opaque {};
43
+ \\
44
+ \\export fn entry() bool {
45
+ \\ var x: i32 = 1;
46
+ \\ return bar(@ptrCast(*MyType, &x));
47
+ \\}
48
+ \\
49
+ \\fn bar(x: *MyType) bool {
50
+ \\ return x.blah;
51
+ \\}
52
+ , &[_ ][]const u8 {
53
+ "tmp.zig:9:13: error: no member named 'blah' in opaque type 'MyType'" ,
54
+ });
55
+
41
56
cases .add ("opaque type with field" ,
42
57
\\const Opaque = opaque { foo: i32 };
43
58
\\export fn entry() void {
@@ -6929,21 +6944,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6929
6944
"tmp.zig:37:29: error: cannot store runtime value in compile time variable" ,
6930
6945
});
6931
6946
6932
- cases .add ("field access of opaque type" ,
6933
- \\const MyType = opaque {};
6934
- \\
6935
- \\export fn entry() bool {
6936
- \\ var x: i32 = 1;
6937
- \\ return bar(@ptrCast(*MyType, &x));
6938
- \\}
6939
- \\
6940
- \\fn bar(x: *MyType) bool {
6941
- \\ return x.blah;
6942
- \\}
6943
- , &[_ ][]const u8 {
6944
- "tmp.zig:9:13: error: type '*MyType' does not support field access" ,
6945
- });
6946
-
6947
6947
cases .add ("invalid legacy unicode escape" ,
6948
6948
\\export fn entry() void {
6949
6949
\\ const a = '\U1234';
0 commit comments