diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-10 00:03:31 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-10 00:03:31 -0700 |
| commit | 49d0971cd4f6aa3f897a0f36272c05c641e25f79 (patch) | |
| tree | 38a52e168cbcf30efddb4b01f4431b4e5c19a30a /test | |
| parent | 1fe1235e14cd599c1b3a6f079670b7cb7ea270d2 (diff) | |
| download | zig-49d0971cd4f6aa3f897a0f36272c05c641e25f79.tar.gz zig-49d0971cd4f6aa3f897a0f36272c05c641e25f79.zip | |
detect and report top level decl dependency loop
Diffstat (limited to 'test')
| -rw-r--r-- | test/run_tests.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 6711346a66..153887e4c3 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -991,6 +991,20 @@ pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { return 0; } )SOURCE", "OK\n"); + + add_simple_case("order-independent declarations", R"SOURCE( +use "std.zig"; +const x : #typeof(y) = 1234; +const y : u16 = 5678; +pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { + print_ok(x) +} +fn print_ok(val: #typeof(x)) -> #typeof(foo) { + print_str("OK\n"); + return 0; +} +const foo : i32 = 0; + )SOURCE", "OK\n"); } @@ -1299,6 +1313,11 @@ fn f() -> i32 { fn f() -> #bogus(foo) { } )SOURCE", 1, ".tmp_source.zig:2:11: error: invalid compiler function: 'bogus'"); + + add_compile_fail_case("top level decl dependency loop", R"SOURCE( +const a : #typeof(b) = 0; +const b : #typeof(a) = 0; + )SOURCE", 1, ".tmp_source.zig:3:19: error: use of undeclared identifier 'a'"); } static void print_compiler_invocation(TestCase *test_case) { |
