| ... | ... | @@ -2881,6 +2881,28 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 2881 | 2881 | |
| 2882 | 2882 | if (var_is_mut) { |
| 2883 | 2883 | try sema.validateVarType(block, ty_src, final_elem_ty, false); |
| 2884 | |
| 2885 | // The value might have been bitcasted into a comptime only |
| 2886 | // pointer type such as `*@Type(.EnumLiteral)` so we must now |
| 2887 | // update all the stores to not give backends invalid AIR. |
| 2888 | |
| 2889 | var air_tags = sema.air_instructions.items(.tag); |
| 2890 | var air_data = sema.air_instructions.items(.data); |
| 2891 | var peer_inst_index: usize = 0; |
| 2892 | var i = ptr_inst; |
| 2893 | while (i < air_tags.len and peer_inst_index < peer_inst_list.len) : (i += 1) { |
| 2894 | if (air_tags[i] != .store) continue; |
| 2895 | if (air_data[i].bin_op.rhs == peer_inst_list[peer_inst_index]) { |
| 2896 | peer_inst_index += 1; |
| 2897 | _ = (try sema.resolveMaybeUndefVal(block, .unneeded, air_data[i].bin_op.rhs)) orelse continue; |
| 2898 | const coerced_val = try sema.coerce(block, final_elem_ty, air_data[i].bin_op.rhs, .unneeded); |
| 2899 | air_tags = sema.air_instructions.items(.tag); |
| 2900 | air_data = sema.air_instructions.items(.data); |
| 2901 | |
| 2902 | air_data[i].bin_op.lhs = ptr; |
| 2903 | air_data[i].bin_op.rhs = coerced_val; |
| 2904 | } |
| 2905 | } |
| 2884 | 2906 | } else ct: { |
| 2885 | 2907 | // Detect if the value is comptime known. In such case, the |
| 2886 | 2908 | // last 3 AIR instructions of the block will look like this: |