diff --git a/compiler/checker/checker.odin b/compiler/checker/checker.odin index f4ea693..dfac274 100644 --- a/compiler/checker/checker.odin +++ b/compiler/checker/checker.odin @@ -6555,11 +6555,12 @@ prune_specs :: proc(checker: ^Checker) { if checker.entry_point == .Process { mark_spec_demanded(checker, find_spec(checker, checker.io_provider_template, nil), &stack) } - for global in checker.ast_module.globals { + for global, index in checker.ast_module.globals { if global.external || global.diagnostic != source.INVALID_DIAGNOSTIC { continue } - _ = infer_expr(checker, global.expr, nil, global.pkg, global.file, &stack) + expected := checker.global_types[index] if is_runtime_type(checker, checker.global_types[index]) else types.INVALID + _ = infer_expr(checker, global.expr, nil, global.pkg, global.file, &stack, expected=expected) } for len(stack) > 0 { id := pop(&stack) diff --git a/examples/programs/arraylist/main.bro b/examples/programs/arraylist/main.bro index 79bde74..a46f325 100644 --- a/examples/programs/arraylist/main.bro +++ b/examples/programs/arraylist/main.bro @@ -10,6 +10,8 @@ State :: struct { diagnostics std.ArrayList(ScanDiagnostic) } +arrlist_test std.ArrayList(Token) = arraylist.init(mem.c_allocator) + hide fail_alloc func(_ ?@mut anyopaque, _ usize, _ usize) ?*mut u8 { return none }