aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-27 12:28:05 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-27 12:28:05 -0700
commitd27b76fc31c33d9381a95ecd5e8567c93bf12eb0 (patch)
treec5fdb9ef94a968c7d706eff57c3758b529d11c7a /test/run_tests.cpp
parentfe0c6a3df9480cc3d0be7412cd24bba4366c18a1 (diff)
downloadzig-d27b76fc31c33d9381a95ecd5e8567c93bf12eb0.tar.gz
zig-d27b76fc31c33d9381a95ecd5e8567c93bf12eb0.zip
add error for `@typeof` or `&` of number literal
closes #85
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 5825dba018..ed833b2858 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -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) {