@@ -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 {
@@ -6893,21 +6908,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6893
6908
"tmp.zig:37:29: error: cannot store runtime value in compile time variable" ,
6894
6909
});
6895
6910
6896
- cases .add ("field access of opaque type" ,
6897
- \\const MyType = opaque {};
6898
- \\
6899
- \\export fn entry() bool {
6900
- \\ var x: i32 = 1;
6901
- \\ return bar(@ptrCast(*MyType, &x));
6902
- \\}
6903
- \\
6904
- \\fn bar(x: *MyType) bool {
6905
- \\ return x.blah;
6906
- \\}
6907
- , &[_ ][]const u8 {
6908
- "tmp.zig:9:13: error: type '*MyType' does not support field access" ,
6909
- });
6910
-
6911
6911
cases .add ("invalid legacy unicode escape" ,
6912
6912
\\export fn entry() void {
6913
6913
\\ const a = '\U1234';
0 commit comments