| author | |
| committer | |
| log | 49d0971cd4f6aa3f897a0f36272c05c641e25f79 |
| tree | 38a52e168cbcf30efddb4b01f4431b4e5c19a30a |
| parent | 1fe1235e14cd599c1b3a6f079670b7cb7ea270d2 |
4 files changed, 26 insertions(+), 9 deletions(-)
src/analyze.cpp+3-1| ... | ... | @@ -3033,7 +3033,9 @@ static void recursive_resolve_decl(CodeGen *g, ImportTableEntry *import, AstNode |
| 3033 | 3033 | AstNode *child_node = unresolved_entry->value; |
| 3034 | 3034 | |
| 3035 | 3035 | if (child_node->codegen_node->decl_node.in_current_deps) { |
| 3036 | zig_panic("TODO infinite top level decl loop"); | |
| 3036 | // dependency loop. we'll let the fact that it's not in the respective | |
| 3037 | // table cause an error in resolve_top_level_decl. | |
| 3038 | continue; | |
| 3037 | 3039 | } |
| 3038 | 3040 | |
| 3039 | 3041 | // set temporary flag |
std/rand.zig+2-4| ... | ... | @@ -3,10 +3,8 @@ const ARRAY_SIZE : u16 = 624; |
| 3 | 3 | |
| 4 | 4 | /// Use `rand_init` to initialize this state. |
| 5 | 5 | pub struct Rand { |
| 6 | // TODO use ARRAY_SIZE here | |
| 7 | array: [624]u32, | |
| 8 | // TODO use #typeof(ARRAY_SIZE) here | |
| 9 | index: u16, | |
| 6 | array: [ARRAY_SIZE]u32, | |
| 7 | index: #typeof(ARRAY_SIZE), | |
| 10 | 8 | |
| 11 | 9 | /// Initialize random state with the given seed. |
| 12 | 10 | pub fn init(r: &Rand, seed: u32) { |
std/std.zig+2-4| ... | ... | @@ -24,8 +24,7 @@ pub fn fprint_str(fd: isize, str: []const u8) -> isize { |
| 24 | 24 | // TODO handle buffering and flushing (mutex protected) |
| 25 | 25 | // TODO error handling |
| 26 | 26 | pub fn print_u64(x: u64) -> isize { |
| 27 | // TODO use max_u64_base10_digits instead of hardcoding 20 | |
| 28 | var buf: [20]u8; | |
| 27 | var buf: [max_u64_base10_digits]u8; | |
| 29 | 28 | const len = buf_print_u64(buf, x); |
| 30 | 29 | return write(stdout_fileno, buf.ptr, len); |
| 31 | 30 | } |
| ... | ... | @@ -33,8 +32,7 @@ pub fn print_u64(x: u64) -> isize { |
| 33 | 32 | // TODO handle buffering and flushing (mutex protected) |
| 34 | 33 | // TODO error handling |
| 35 | 34 | pub fn print_i64(x: i64) -> isize { |
| 36 | // TODO use max_u64_base10_digits instead of hardcoding 20 | |
| 37 | var buf: [20]u8; | |
| 35 | var buf: [max_u64_base10_digits]u8; | |
| 38 | 36 | const len = buf_print_i64(buf, x); |
| 39 | 37 | return write(stdout_fileno, buf.ptr, len); |
| 40 | 38 | } |
test/run_tests.cpp+19| ... | ... | @@ -991,6 +991,20 @@ pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { |
| 991 | 991 | return 0; |
| 992 | 992 | } |
| 993 | 993 | )SOURCE", "OK\n"); |
| 994 | ||
| 995 | add_simple_case("order-independent declarations", R"SOURCE( | |
| 996 | use "std.zig"; | |
| 997 | const x : #typeof(y) = 1234; | |
| 998 | const y : u16 = 5678; | |
| 999 | pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { | |
| 1000 | print_ok(x) | |
| 1001 | } | |
| 1002 | fn print_ok(val: #typeof(x)) -> #typeof(foo) { | |
| 1003 | print_str("OK\n"); | |
| 1004 | return 0; | |
| 1005 | } | |
| 1006 | const foo : i32 = 0; | |
| 1007 | )SOURCE", "OK\n"); | |
| 994 | 1008 | } |
| 995 | 1009 | |
| 996 | 1010 | |
| ... | ... | @@ -1299,6 +1313,11 @@ fn f() -> i32 { |
| 1299 | 1313 | fn f() -> #bogus(foo) { |
| 1300 | 1314 | } |
| 1301 | 1315 | )SOURCE", 1, ".tmp_source.zig:2:11: error: invalid compiler function: 'bogus'"); |
| 1316 | ||
| 1317 | add_compile_fail_case("top level decl dependency loop", R"SOURCE( | |
| 1318 | const a : #typeof(b) = 0; | |
| 1319 | const b : #typeof(a) = 0; | |
| 1320 | )SOURCE", 1, ".tmp_source.zig:3:19: error: use of undeclared identifier 'a'"); | |
| 1302 | 1321 | } |
| 1303 | 1322 | |
| 1304 | 1323 | static void print_compiler_invocation(TestCase *test_case) { |