diff options
| author | Matthew McAllister <matthew.mcallister.0@gmail.com> | 2019-02-01 03:12:56 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-01 17:14:12 -0500 |
| commit | 8bedb10939b511e39787b2693249d2d3e8102854 (patch) | |
| tree | a9c1149afe28219dba160000c86af06396efe6fe /test/compile_errors.zig | |
| parent | ae1ebe09b7c1258bfa8de37244fd9b510b1447a4 (diff) | |
| download | zig-8bedb10939b511e39787b2693249d2d3e8102854.tar.gz zig-8bedb10939b511e39787b2693249d2d3e8102854.zip | |
Fix runtime assignment to comptime aggregate field
This was causing a segfault
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 74602b77ff..30d9ca5d70 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -5367,4 +5367,32 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { , ".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_float", ); + + cases.add( + "runtime assignment to comptime struct type", + \\const Foo = struct { + \\ Bar: u8, + \\ Baz: type, + \\}; + \\export fn f() void { + \\ var x: u8 = 0; + \\ const foo = Foo { .Bar = x, .Baz = u8 }; + \\} + , + ".tmp_source.zig:7:30: error: unable to evaluate constant expression", + ); + + cases.add( + "runtime assignment to comptime union type", + \\const Foo = union { + \\ Bar: u8, + \\ Baz: type, + \\}; + \\export fn f() void { + \\ var x: u8 = 0; + \\ const foo = Foo { .Bar = x }; + \\} + , + ".tmp_source.zig:7:30: error: unable to evaluate constant expression", + ); } |
