motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 0b6cf0aa637b5cd7551aca295832f06d56315921 (tree)
parent 8106f9846aea806350d319535e0181104299ba5d
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Sun, 15 Jan 2017 22:34:20 -0500

fix handling of invalid enumeration

Diffstat:
Msrc/ir.cpp | 5+++--
Mtest/run_tests.cpp | 4+---
2 files changed, 4 insertions(+), 5 deletions(-)

diff --git 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 @@ -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 {