diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-05-25 23:47:44 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:47:55 -0700 |
| commit | 5d0d5893fd39047e4fdbb6623e4d69babf0b2ed4 (patch) | |
| tree | 1ee6e3c66906d7b5485c2e35dcccf1009799d365 /src/Sema.zig | |
| parent | 70cc68e9994f7dca53904075e15b2b6f87342539 (diff) | |
| download | zig-5d0d5893fd39047e4fdbb6623e4d69babf0b2ed4.tar.gz zig-5d0d5893fd39047e4fdbb6623e4d69babf0b2ed4.zip | |
Sema: fix some issues with the inferred alloc tag change
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 55adc2fffb..6927a4bde9 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -1999,15 +1999,17 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime( return opv; } const air_datas = sema.air_instructions.items(.data); - switch (air_tags[i]) { - .interned => { - const val = air_datas[i].interned.toValue(); - if (val.isRuntimeValue(sema.mod)) make_runtime.* = true; - if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true; - return val; + const val = switch (air_tags[i]) { + .inferred_alloc, .inferred_alloc_comptime => val: { + const ty_pl = sema.air_instructions.items(.data)[i].ty_pl; + break :val sema.air_values.items[ty_pl.payload]; }, + .interned => air_datas[i].interned.toValue(), else => return null, - } + }; + if (val.isRuntimeValue(sema.mod)) make_runtime.* = true; + if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true; + return val; } fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc, reason: []const u8) CompileError { @@ -3762,13 +3764,17 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com sema.air_instructions.items(.data)[ptr_inst].ty_pl.ty = final_ptr_ty_inst; try sema.maybeQueueFuncBodyAnalysis(decl_index); - sema.air_values.items[value_index] = (try sema.mod.intern(.{ .ptr = .{ - .ty = final_ptr_ty.toIntern(), - .addr = if (var_is_mut) .{ .mut_decl = .{ - .decl = decl_index, - .runtime_index = block.runtime_index, - } } else .{ .decl = decl_index }, - } })).toValue(); + // Change it to an interned. + sema.air_instructions.set(ptr_inst, .{ + .tag = .interned, + .data = .{ .interned = try sema.mod.intern(.{ .ptr = .{ + .ty = final_ptr_ty.toIntern(), + .addr = if (var_is_mut) .{ .mut_decl = .{ + .decl = decl_index, + .runtime_index = block.runtime_index, + } } else .{ .decl = decl_index }, + } }) }, + }); }, .inferred_alloc => { assert(sema.unresolved_inferred_allocs.remove(ptr_inst)); |
