fix crash in non-const expression in struct literal outside fn

This commit is contained in:
Andrew Kelley
2016-04-18 18:18:41 -07:00
parent f4c7e1bf49
commit ff1ab3fe9c
2 changed files with 18 additions and 1 deletions

View File

@@ -1191,6 +1191,15 @@ fn fibbonaci(x: i32) -> i32 {
add_compile_fail_case("@embed_file with bogus file", R"SOURCE(
const resource = @embed_file("bogus.txt");
)SOURCE", 1, ".tmp_source.zig:2:18: error: unable to find './bogus.txt'");
add_compile_fail_case("non-const expression in struct literal outside function", R"SOURCE(
struct Foo {
x: i32,
}
const a = Foo {.x = get_it()};
extern fn get_it() -> i32;
)SOURCE", 1, ".tmp_source.zig:5:27: error: unable to evaluate constant expression");
}
//////////////////////////////////////////////////////////////////////////////