mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
fix regression with optionals and globals
This commit is contained in:
parent
b952b84486
commit
6a8c9f7306
15
src/ir.cpp
15
src/ir.cpp
@ -17606,12 +17606,15 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
|
||||
if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
|
||||
value_type->id != ZigTypeIdNull)
|
||||
{
|
||||
bool has_bits;
|
||||
if ((err = type_has_bits2(ira->codegen, value_type, &has_bits)))
|
||||
return ira->codegen->invalid_instruction;
|
||||
if (has_bits) {
|
||||
result_loc_pass1->written = false;
|
||||
return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
|
||||
bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);
|
||||
if (!same_comptime_repr) {
|
||||
bool has_bits;
|
||||
if ((err = type_has_bits2(ira->codegen, value_type, &has_bits)))
|
||||
return ira->codegen->invalid_instruction;
|
||||
if (has_bits) {
|
||||
result_loc_pass1->written = false;
|
||||
return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
|
||||
}
|
||||
}
|
||||
} else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) {
|
||||
bool has_bits;
|
||||
|
||||
@ -82,7 +82,7 @@ comptime {
|
||||
_ = @import("behavior/namespace_depends_on_compile_var.zig");
|
||||
_ = @import("behavior/new_stack_call.zig");
|
||||
_ = @import("behavior/null.zig");
|
||||
//_ = @import("behavior/optional.zig");
|
||||
_ = @import("behavior/optional.zig");
|
||||
_ = @import("behavior/pointers.zig");
|
||||
_ = @import("behavior/popcount.zig");
|
||||
_ = @import("behavior/ptrcast.zig");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user