@@ -2,6 +2,21 @@ const tests = @import("tests.zig");
2
2
const std = @import ("std" );
3
3
4
4
pub fn addCases (cases : * tests.CompileErrorContext ) void {
5
+ cases .add ("field access of opaque type" ,
6
+ \\const MyType = opaque {};
7
+ \\
8
+ \\export fn entry() bool {
9
+ \\ var x: i32 = 1;
10
+ \\ return bar(@ptrCast(*MyType, &x));
11
+ \\}
12
+ \\
13
+ \\fn bar(x: *MyType) bool {
14
+ \\ return x.blah;
15
+ \\}
16
+ , &[_ ][]const u8 {
17
+ "tmp.zig:9:13: error: no member named 'blah' in opaque type 'MyType'" ,
18
+ });
19
+
5
20
cases .add ("opaque type with field" ,
6
21
\\const Opaque = opaque { foo: i32 };
7
22
\\export fn entry() void {
@@ -6885,21 +6900,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6885
6900
"tmp.zig:37:29: error: cannot store runtime value in compile time variable" ,
6886
6901
});
6887
6902
6888
- cases .add ("field access of opaque type" ,
6889
- \\const MyType = opaque {};
6890
- \\
6891
- \\export fn entry() bool {
6892
- \\ var x: i32 = 1;
6893
- \\ return bar(@ptrCast(*MyType, &x));
6894
- \\}
6895
- \\
6896
- \\fn bar(x: *MyType) bool {
6897
- \\ return x.blah;
6898
- \\}
6899
- , &[_ ][]const u8 {
6900
- "tmp.zig:9:13: error: type '*MyType' does not support field access" ,
6901
- });
6902
-
6903
6903
cases .add ("invalid legacy unicode escape" ,
6904
6904
\\export fn entry() void {
6905
6905
\\ const a = '\U1234';
0 commit comments