error for non const expr in array size outside fn

This commit is contained in:
Andrew Kelley
2016-02-07 15:16:36 -07:00
parent 26ea20d88f
commit 36cf9f0c72
2 changed files with 12 additions and 1 deletions

View File

@@ -2027,6 +2027,13 @@ fn a(x: i32) {
const y = @const_eval(x);
}
)SOURCE", 1, ".tmp_source.zig:3:27: error: unable to evaluate constant expression");
add_compile_fail_case("non constant expression in array size outside function", R"SOURCE(
struct Foo {
y: [get()]u8,
}
fn get() -> isize { 1 }
)SOURCE", 1, ".tmp_source.zig:3:9: error: unable to evaluate constant expression");
}
//////////////////////////////////////////////////////////////////////////////