add error for @typeof or & of number literal

closes #85
This commit is contained in:
Andrew Kelley
2016-01-27 12:28:05 -07:00
parent fe0c6a3df9
commit d27b76fc31
2 changed files with 43 additions and 5 deletions

View File

@@ -999,7 +999,7 @@ pub fn main(args: [][]u8) -> %void {
add_simple_case("order-independent declarations", R"SOURCE(
import "std.zig";
const z : @typeof(stdin_fileno) = 0;
const z = stdin_fileno;
const x : @typeof(y) = 1234;
const y : u16 = 5678;
pub fn main(args: [][]u8) -> %void {
@@ -1683,6 +1683,18 @@ c_import {
add_compile_fail_case("empty file", "",
1, ".tmp_source.zig:1:1: error: missing export declaration and output name not provided");
add_compile_fail_case("address of number literal", R"SOURCE(
const x = 3;
const y = &x;
)SOURCE", 1, ".tmp_source.zig:3:12: error: unable to get address of type '(integer literal)'");
add_compile_fail_case("@typeof number literal", R"SOURCE(
const x = 3;
struct Foo {
index: @typeof(x),
}
)SOURCE", 1, ".tmp_source.zig:4:20: error: type '(integer literal)' not eligible for @typeof");
}
static void print_compiler_invocation(TestCase *test_case) {