diff options
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index fd27b8e666..3d7677ab75 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,29 @@ const tests = @import("tests.zig"); const std = @import("std"); pub fn addCases(cases: *tests.CompileErrorContext) void { + cases.add("call assigned to constant", + \\const Foo = struct { + \\ x: i32, + \\}; + \\fn foo() Foo { + \\ return .{ .x = 42 }; + \\} + \\fn bar(val: var) Foo { + \\ return .{ .x = val }; + \\} + \\export fn entry() void { + \\ const baz: Foo = undefined; + \\ baz = foo(); + \\} + \\export fn entry1() void { + \\ const baz: Foo = undefined; + \\ baz = bar(42); + \\} + , &[_][]const u8{ + "tmp.zig:12:14: error: cannot assign to constant", + "tmp.zig:16:14: error: cannot assign to constant", + }); + cases.add("invalid pointer syntax", \\export fn foo() void { \\ var guid: *:0 const u8 = undefined; |
