authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-09-26 11:55:56-06:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-10-06 22:08:30-06:00
logbf4bfe54ac13512d7553a7be83ae19e908e9c294
treec07c67a871c9a342caba87afea46c9a785216331
parent6b8ae6fffb71128169de447851244869aebb882b
signaturelock-open Commit is signed but in an unrecognized format.

Update compile error test for field access of opaque type


2 files changed, 17 insertions(+), 15 deletions(-)

src/stage1/ir.cpp+2
......@@ -22387,6 +22387,8 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira,
2238722387 prefix_name = "enum ";
2238822388 } else if (bare_struct_type->id == ZigTypeIdUnion) {
2238922389 prefix_name = "union ";
22390 } else if (bare_struct_type->id == ZigTypeIdOpaque) {
22391 prefix_name = "opaque type ";
2239022392 } else {
2239122393 prefix_name = "";
2239222394 }
test/compile_errors.zig+15-15
......@@ -126,6 +126,21 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
126126 "tmp.zig:27:24: note: referenced here",
127127 });
128128
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
129144 cases.add("opaque type with field",
130145 \\const Opaque = opaque { foo: i32 };
131146 \\export fn entry() void {
......@@ -7029,21 +7044,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
70297044 "tmp.zig:37:29: error: cannot store runtime value in compile time variable",
70307045 });
70317046
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
70477047 cases.add("invalid legacy unicode escape",
70487048 \\export fn entry() void {
70497049 \\ const a = '\U1234';