add regression test for invalid multiple dereferences

closes #1042
This commit is contained in:
Andrew Kelley 2019-03-16 00:23:18 -04:00
parent c40448eb9a
commit 6d6195424d
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -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;