diff --git a/src/ir.cpp b/src/ir.cpp index cd72d029d4..f78186e1ba 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7936,9 +7936,10 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op IrInstruction *value = un_op_instruction->value->other; TypeTableEntry *type_entry = ir_resolve_type(ira, value); TypeTableEntry *canon_type = get_underlying_type(type_entry); + if (type_is_invalid(canon_type)) + return ira->codegen->builtin_types.entry_invalid; switch (canon_type->id) { case TypeTableEntryIdInvalid: - return ira->codegen->builtin_types.entry_invalid; case TypeTableEntryIdVar: case TypeTableEntryIdTypeDecl: zig_unreachable(); @@ -9997,7 +9998,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) { IrInstruction *container_type_value = instruction->container_type->other; TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value); - if (container_type->id == TypeTableEntryIdInvalid) + if (type_is_invalid(container_type)) return ira->codegen->builtin_types.entry_invalid; bool depends_on_compile_var = container_type_value->value.depends_on_compile_var; diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 2a9bb72670..91f9e74db1 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1521,9 +1521,7 @@ fn foo() { jll.init(1234); var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} }; } - )SOURCE", 2, - ".tmp_source.zig:6:16: error: use of undeclared identifier 'JsonList'", - ".tmp_source.zig:27:8: error: no member named 'init' in 'JsonNode'"); + )SOURCE", 1, ".tmp_source.zig:6:16: error: use of undeclared identifier 'JsonList'"); add_compile_fail_case("method call with first arg type primitive", R"SOURCE( const Foo = struct {