aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-18 10:49:21 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-18 10:49:21 -0400
commitfdc6e0af056e72ee47a296e7d8fbb365dc00c058 (patch)
tree50226b0ba024289d6c1eccee5c014e29c1009509 /src
parente5a0414b05134bfebba4fba097ae882ee0cf36cf (diff)
downloadzig-fdc6e0af056e72ee47a296e7d8fbb365dc00c058.tar.gz
zig-fdc6e0af056e72ee47a296e7d8fbb365dc00c058.zip
fix zero length array literal casted to slice
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp16
1 files changed, 14 insertions, 2 deletions
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<ResultLocPeer *>(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: