fix no error emitted for redeclaring global var

closes #81
This commit is contained in:
Andrew Kelley
2016-01-23 00:07:08 -07:00
parent bfceb18631
commit 1543043bf5
4 changed files with 103 additions and 41 deletions

View File

@@ -1484,6 +1484,21 @@ struct A { x : i32, }
struct A { y : i32, }
)SOURCE", 1, ".tmp_source.zig:3:1: error: redefinition of 'A'");
add_compile_fail_case("redefinition of enums", R"SOURCE(
enum A {}
enum A {}
)SOURCE", 1, ".tmp_source.zig:3:1: error: redefinition of 'A'");
add_compile_fail_case("redefinition of error values", R"SOURCE(
%.A;
%.A;
)SOURCE", 1, ".tmp_source.zig:3:1: error: redefinition of error 'A'");
add_compile_fail_case("redefinition of global variables", R"SOURCE(
var a : i32 = 1;
var a : i32 = 2;
)SOURCE", 1, ".tmp_source.zig:3:1: error: redeclaration of variable 'a'");
add_compile_fail_case("byvalue struct on exported functions", R"SOURCE(
struct A { x : i32, }
export fn f(a : A) => {}
@@ -1608,6 +1623,7 @@ extern {
}
const x = foo();
)SOURCE", 1, ".tmp_source.zig:5:11: error: global variable initializer requires constant expression");
}
static void print_compiler_invocation(TestCase *test_case) {