add error for shadowing a type

closes #61
This commit is contained in:
Andrew Kelley
2016-01-18 17:04:37 -07:00
parent 32821e7098
commit ea21d2beb6
2 changed files with 22 additions and 0 deletions

View File

@@ -1501,6 +1501,16 @@ const foo = []u16{.x = 1024,};
add_compile_fail_case("type variables must be constant", R"SOURCE(
var foo = u8;
)SOURCE", 1, ".tmp_source.zig:2:1: error: variable of type 'type' must be constant");
add_compile_fail_case("variables shadowing types", R"SOURCE(
struct Foo {}
struct Bar {}
fn f(Foo: i32) => {
var Bar : i32;
}
)SOURCE", 2, ".tmp_source.zig:5:6: error: variable shadows type 'Foo'",
".tmp_source.zig:6:5: error: variable shadows type 'Bar'");
}
static void print_compiler_invocation(TestCase *test_case) {