| ... | @@ -126,6 +126,21 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -126,6 +126,21 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 126 | "tmp.zig:27:24: note: referenced here", | 126 | "tmp.zig:27:24: note: referenced here", |
| 127 | }); | 127 | }); |
| 128 | | 128 | |
| | 129 | cases.add("field access of opaque type", |
| | 130 | \\const MyType = opaque {}; |
| | 131 | \\ |
| | 132 | \\export fn entry() bool { |
| | 133 | \\ var x: i32 = 1; |
| | 134 | \\ return bar(@ptrCast(*MyType, &x)); |
| | 135 | \\} |
| | 136 | \\ |
| | 137 | \\fn bar(x: *MyType) bool { |
| | 138 | \\ return x.blah; |
| | 139 | \\} |
| | 140 | , &[_][]const u8{ |
| | 141 | "tmp.zig:9:13: error: no member named 'blah' in opaque type 'MyType'", |
| | 142 | }); |
| | 143 | |
| 129 | cases.add("opaque type with field", | 144 | cases.add("opaque type with field", |
| 130 | \\const Opaque = opaque { foo: i32 }; | 145 | \\const Opaque = opaque { foo: i32 }; |
| 131 | \\export fn entry() void { | 146 | \\export fn entry() void { |
| ... | @@ -7029,21 +7044,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -7029,21 +7044,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 7029 | "tmp.zig:37:29: error: cannot store runtime value in compile time variable", | 7044 | "tmp.zig:37:29: error: cannot store runtime value in compile time variable", |
| 7030 | }); | 7045 | }); |
| 7031 | | 7046 | |
| 7032 | cases.add("field access of opaque type", | | |
| 7033 | \\const MyType = opaque {}; | | |
| 7034 | \\ | | |
| 7035 | \\export fn entry() bool { | | |
| 7036 | \\ var x: i32 = 1; | | |
| 7037 | \\ return bar(@ptrCast(*MyType, &x)); | | |
| 7038 | \\} | | |
| 7039 | \\ | | |
| 7040 | \\fn bar(x: *MyType) bool { | | |
| 7041 | \\ return x.blah; | | |
| 7042 | \\} | | |
| 7043 | , &[_][]const u8{ | | |
| 7044 | "tmp.zig:9:13: error: type '*MyType' does not support field access", | | |
| 7045 | }); | | |
| 7046 | | | |
| 7047 | cases.add("invalid legacy unicode escape", | 7047 | cases.add("invalid legacy unicode escape", |
| 7048 | \\export fn entry() void { | 7048 | \\export fn entry() void { |
| 7049 | \\ const a = '\U1234'; | 7049 | \\ const a = '\U1234'; |