diff options
| author | Matthew McAllister <matthew.mcallister.0@gmail.com> | 2019-02-12 21:22:16 -0800 |
|---|---|---|
| committer | Matthew McAllister <matthew.mcallister.0@gmail.com> | 2019-02-16 17:37:47 -0800 |
| commit | 91989e70ba68e3543acffef079d97c9416b5259c (patch) | |
| tree | 71323c9859706b377290c5bbca22c661afaf60dc /test/compile_errors.zig | |
| parent | c3c92ca8b1ada4faed14a9770ab7ed6536edaa15 (diff) | |
| download | zig-91989e70ba68e3543acffef079d97c9416b5259c.tar.gz zig-91989e70ba68e3543acffef079d97c9416b5259c.zip | |
Fix lvalue dereference type checking
Previously, if a dereference instruction was an lvalue, it would fail to
typecheck that the value being dereferenced was indeed a pointer.
Although a little clunky, this change obviates the need for redundant
type checks scattered about the analysis.
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 9ef4af4162..f2f08c4323 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -138,6 +138,24 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { ); cases.addTest( + "assign to invalid dereference", + \\export fn entry() void { + \\ 'a'.* = 1; + \\} + , + ".tmp_source.zig:2:8: error: attempt to dereference non-pointer type 'comptime_int'", + ); + + cases.addTest( + "take slice of invalid dereference", + \\export fn entry() void { + \\ const x = 'a'.*[0..]; + \\} + , + ".tmp_source.zig:2:18: error: attempt to dereference non-pointer type 'comptime_int'", + ); + + cases.addTest( "@truncate undefined value", \\export fn entry() void { \\ var z = @truncate(u8, u16(undefined)); @@ -447,7 +465,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ _ = a.*.len; \\} , - ".tmp_source.zig:3:12: error: attempt to dereference non-pointer type '[]u8'", + ".tmp_source.zig:3:10: error: attempt to dereference non-pointer type '[]u8'", ); cases.add( @@ -1158,7 +1176,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ Filled, \\}; , - ".tmp_source.zig:3:17: error: invalid deref on switch target", + ".tmp_source.zig:3:17: error: attempt to dereference non-pointer type 'Tile'", ); cases.add( @@ -4000,7 +4018,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ \\export fn entry() usize { return @sizeOf(@typeOf(pass)); } , - ".tmp_source.zig:4:10: error: attempt to dereference non pointer type '[10]u8'", + ".tmp_source.zig:4:10: error: attempt to dereference non-pointer type '[10]u8'", ); cases.add( |
