| 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,7 +3033,9 @@ static void recursive_resolve_decl(CodeGen *g, ImportTableEntry *import, AstNode |
| 3033 | AstNode *child_node = unresolved_entry->value; | 3033 | AstNode *child_node = unresolved_entry->value; |
| 3034 | 3034 | ||
| 3035 | if (child_node->codegen_node->decl_node.in_current_deps) { | 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 | // set temporary flag | 3041 | // set temporary flag |
std/rand.zig+2-4| ... | @@ -3,10 +3,8 @@ const ARRAY_SIZE : u16 = 624; | ... | @@ -3,10 +3,8 @@ const ARRAY_SIZE : u16 = 624; |
| 3 | 3 | ||
| 4 | /// Use `rand_init` to initialize this state. | 4 | /// Use `rand_init` to initialize this state. |
| 5 | pub struct Rand { | 5 | pub struct Rand { |
| 6 | // TODO use ARRAY_SIZE here | 6 | array: [ARRAY_SIZE]u32, |
| 7 | array: [624]u32, | 7 | index: #typeof(ARRAY_SIZE), |
| 8 | // TODO use #typeof(ARRAY_SIZE) here | ||
| 9 | index: u16, | ||
| 10 | 8 | ||
| 11 | /// Initialize random state with the given seed. | 9 | /// Initialize random state with the given seed. |
| 12 | pub fn init(r: &Rand, seed: u32) { | 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,8 +24,7 @@ pub fn fprint_str(fd: isize, str: []const u8) -> isize { |
| 24 | // TODO handle buffering and flushing (mutex protected) | 24 | // TODO handle buffering and flushing (mutex protected) |
| 25 | // TODO error handling | 25 | // TODO error handling |
| 26 | pub fn print_u64(x: u64) -> isize { | 26 | pub fn print_u64(x: u64) -> isize { |
| 27 | // TODO use max_u64_base10_digits instead of hardcoding 20 | 27 | var buf: [max_u64_base10_digits]u8; |
| 28 | var buf: [20]u8; | ||
| 29 | const len = buf_print_u64(buf, x); | 28 | const len = buf_print_u64(buf, x); |
| 30 | return write(stdout_fileno, buf.ptr, len); | 29 | return write(stdout_fileno, buf.ptr, len); |
| 31 | } | 30 | } |
| ... | @@ -33,8 +32,7 @@ pub fn print_u64(x: u64) -> isize { | ... | @@ -33,8 +32,7 @@ pub fn print_u64(x: u64) -> isize { |
| 33 | // TODO handle buffering and flushing (mutex protected) | 32 | // TODO handle buffering and flushing (mutex protected) |
| 34 | // TODO error handling | 33 | // TODO error handling |
| 35 | pub fn print_i64(x: i64) -> isize { | 34 | pub fn print_i64(x: i64) -> isize { |
| 36 | // TODO use max_u64_base10_digits instead of hardcoding 20 | 35 | var buf: [max_u64_base10_digits]u8; |
| 37 | var buf: [20]u8; | ||
| 38 | const len = buf_print_i64(buf, x); | 36 | const len = buf_print_i64(buf, x); |
| 39 | return write(stdout_fileno, buf.ptr, len); | 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,6 +991,20 @@ pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { |
| 991 | return 0; | 991 | return 0; |
| 992 | } | 992 | } |
| 993 | )SOURCE", "OK\n"); | 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,6 +1313,11 @@ fn f() -> i32 { |
| 1299 | fn f() -> #bogus(foo) { | 1313 | fn f() -> #bogus(foo) { |
| 1300 | } | 1314 | } |
| 1301 | )SOURCE", 1, ".tmp_source.zig:2:11: error: invalid compiler function: 'bogus'"); | 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 | static void print_compiler_invocation(TestCase *test_case) { | 1323 | static void print_compiler_invocation(TestCase *test_case) { |