@@ -73,6 +73,21 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
73
73
"tmp.zig:27:24: note: referenced here" ,
74
74
});
75
75
76
+ cases .add ("field access of opaque type" ,
77
+ \\const MyType = opaque {};
78
+ \\
79
+ \\export fn entry() bool {
80
+ \\ var x: i32 = 1;
81
+ \\ return bar(@ptrCast(*MyType, &x));
82
+ \\}
83
+ \\
84
+ \\fn bar(x: *MyType) bool {
85
+ \\ return x.blah;
86
+ \\}
87
+ , &[_ ][]const u8 {
88
+ "tmp.zig:9:13: error: no member named 'blah' in opaque type 'MyType'" ,
89
+ });
90
+
76
91
cases .add ("opaque type with field" ,
77
92
\\const Opaque = opaque { foo: i32 };
78
93
\\export fn entry() void {
@@ -6976,21 +6991,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6976
6991
"tmp.zig:37:29: error: cannot store runtime value in compile time variable" ,
6977
6992
});
6978
6993
6979
- cases .add ("field access of opaque type" ,
6980
- \\const MyType = opaque {};
6981
- \\
6982
- \\export fn entry() bool {
6983
- \\ var x: i32 = 1;
6984
- \\ return bar(@ptrCast(*MyType, &x));
6985
- \\}
6986
- \\
6987
- \\fn bar(x: *MyType) bool {
6988
- \\ return x.blah;
6989
- \\}
6990
- , &[_ ][]const u8 {
6991
- "tmp.zig:9:13: error: type '*MyType' does not support field access" ,
6992
- });
6993
-
6994
6994
cases .add ("invalid legacy unicode escape" ,
6995
6995
\\export fn entry() void {
6996
6996
\\ const a = '\U1234';
0 commit comments