From fdc6e0af056e72ee47a296e7d8fbb365dc00c058 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 18 Jun 2019 10:49:21 -0400 Subject: fix zero length array literal casted to slice --- src/ir.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index e3c9855c75..f4ccdfc6a2 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15119,8 +15119,11 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrIn old_result_loc = reinterpret_cast(instruction->result_loc)->parent->parent; continue; } - ir_assert(false, &instruction->base); // TODO - zig_unreachable(); + IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type); + result->value.special = ConstValSpecialUndef; + IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false); + ptr->value.data.x_ptr.mut = ConstPtrMutComptimeVar; + return ptr; } } @@ -19212,6 +19215,15 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, return ira->codegen->invalid_instruction; } + switch (type_has_one_possible_value(ira->codegen, container_type)) { + case OnePossibleValueInvalid: + return ira->codegen->invalid_instruction; + case OnePossibleValueYes: + return ir_const(ira, &instruction->base, container_type); + case OnePossibleValueNo: + break; + } + bool is_comptime; switch (type_requires_comptime(ira->codegen, container_type)) { case ReqCompTimeInvalid: -- cgit v1.2.3