Resolve more types as needed

Closes #3994
This commit is contained in:
LemonBoy
2019-12-30 16:48:14 +01:00
committed by Andrew Kelley
parent c1ee846c22
commit 28a8ded95a
4 changed files with 54 additions and 21 deletions

View File

@@ -1725,11 +1725,14 @@ static void gen_var_debug_decl(CodeGen *g, ZigVar *var) {
static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) {
Error err;
if ((err = type_resolve(g, instruction->value->type, ResolveStatusZeroBitsKnown))) {
bool value_has_bits;
if ((err = type_has_bits2(g, instruction->value->type, &value_has_bits)))
codegen_report_errors_and_exit(g);
}
if (!type_has_bits(instruction->value->type))
if (!value_has_bits)
return nullptr;
if (!instruction->llvm_value) {
if (instruction->id == IrInstructionIdAwaitGen) {
IrInstructionAwaitGen *await = reinterpret_cast<IrInstructionAwaitGen*>(instruction);
@@ -5560,13 +5563,21 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab
static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *executable,
IrInstructionUnwrapErrPayload *instruction)
{
Error err;
if (instruction->base.value->special != ConstValSpecialRuntime)
return nullptr;
bool want_safety = instruction->safety_check_on && ir_want_runtime_safety(g, &instruction->base) &&
g->errors_by_index.length > 1;
if (!want_safety && !type_has_bits(instruction->base.value->type))
bool value_has_bits;
if ((err = type_has_bits2(g, instruction->base.value->type, &value_has_bits)))
codegen_report_errors_and_exit(g);
if (!want_safety && !value_has_bits)
return nullptr;
ZigType *ptr_type = instruction->value->value->type;
assert(ptr_type->id == ZigTypeIdPointer);
ZigType *err_union_type = ptr_type->data.pointer.child_type;