diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 2ab5824de5..f0c5b6a450 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,25 @@ const tests = @import("tests.zig"); const builtin = @import("builtin"); pub fn addCases(cases: *tests.CompileErrorContext) void { + cases.add( + "invalid multiple dereferences", + \\export fn a() void { + \\ var box = Box{ .field = 0 }; + \\ box.*.field = 1; + \\} + \\export fn b() void { + \\ var box = Box{ .field = 0 }; + \\ var boxPtr = &box; + \\ boxPtr.*.*.field = 1; + \\} + \\pub const Box = struct { + \\ field: i32, + \\}; + , + "tmp.zig:3:8: error: attempt to dereference non-pointer type 'Box'", + "tmp.zig:8:13: error: attempt to dereference non-pointer type 'Box'", + ); + cases.add( "usingnamespace with wrong type", \\use void;