| ... | @@ -2623,10 +2623,9 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -2623,10 +2623,9 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 2623 | // block so that codegen does not see it. | 2623 | // block so that codegen does not see it. |
| 2624 | block.instructions.shrinkRetainingCapacity(block.instructions.items.len - 3); | 2624 | block.instructions.shrinkRetainingCapacity(block.instructions.items.len - 3); |
| 2625 | sema.air_values.items[value_index] = try Value.Tag.decl_ref.create(sema.arena, new_decl); | 2625 | sema.air_values.items[value_index] = try Value.Tag.decl_ref.create(sema.arena, new_decl); |
| 2626 | // Would be nice if we could just assign `bitcast_ty_ref` to | 2626 | // if bitcast ty ref needs to be made const, make_ptr_const |
| 2627 | // `air_datas[ptr_inst].ty_pl.ty`, wouldn't it? Alas, that is almost correct, | 2627 | // ZIR handles it later, so we can just use the ty ref here. |
| 2628 | // except that the pointer is mutable and we need to make it constant here. | 2628 | air_datas[ptr_inst].ty_pl.ty = air_datas[bitcast_inst].ty_op.ty; |
| 2629 | air_datas[ptr_inst].ty_pl.ty = try sema.addType(final_ptr_ty); | | |
| 2630 | | 2629 | |
| 2631 | return; | 2630 | return; |
| 2632 | } | 2631 | } |
| ... | @@ -11828,21 +11827,16 @@ fn zirArrayInit( | ... | @@ -11828,21 +11827,16 @@ fn zirArrayInit( |
| 11828 | }); | 11827 | }); |
| 11829 | }; | 11828 | }; |
| 11830 | | 11829 | |
| 11831 | const elems = if (!is_sent) | 11830 | const opt_runtime_src: ?LazySrcLoc = for (resolved_args) |arg| { |
| 11832 | resolved_args | | |
| 11833 | else | | |
| 11834 | resolved_args[0 .. resolved_args.len - 1]; | | |
| 11835 | | | |
| 11836 | const opt_runtime_src: ?LazySrcLoc = for (elems) |arg| { | | |
| 11837 | const arg_src = src; // TODO better source location | 11831 | const arg_src = src; // TODO better source location |
| 11838 | const comptime_known = try sema.isComptimeKnown(block, arg_src, arg); | 11832 | const comptime_known = try sema.isComptimeKnown(block, arg_src, arg); |
| 11839 | if (!comptime_known) break arg_src; | 11833 | if (!comptime_known) break arg_src; |
| 11840 | } else null; | 11834 | } else null; |
| 11841 | | 11835 | |
| 11842 | const runtime_src = opt_runtime_src orelse { | 11836 | const runtime_src = opt_runtime_src orelse { |
| 11843 | const elem_vals = try sema.arena.alloc(Value, elems.len); | 11837 | const elem_vals = try sema.arena.alloc(Value, resolved_args.len); |
| 11844 | | 11838 | |
| 11845 | for (elems) |arg, i| { | 11839 | for (resolved_args) |arg, i| { |
| 11846 | // We checked that all args are comptime above. | 11840 | // We checked that all args are comptime above. |
| 11847 | elem_vals[i] = (sema.resolveMaybeUndefVal(block, src, arg) catch unreachable).?; | 11841 | elem_vals[i] = (sema.resolveMaybeUndefVal(block, src, arg) catch unreachable).?; |
| 11848 | } | 11842 | } |
| ... | @@ -11869,7 +11863,7 @@ fn zirArrayInit( | ... | @@ -11869,7 +11863,7 @@ fn zirArrayInit( |
| 11869 | }); | 11863 | }); |
| 11870 | const elem_ptr_ty_ref = try sema.addType(elem_ptr_ty); | 11864 | const elem_ptr_ty_ref = try sema.addType(elem_ptr_ty); |
| 11871 | | 11865 | |
| 11872 | for (elems) |arg, i| { | 11866 | for (resolved_args) |arg, i| { |
| 11873 | const index = try sema.addIntUnsigned(Type.usize, i); | 11867 | const index = try sema.addIntUnsigned(Type.usize, i); |
| 11874 | const elem_ptr = try block.addPtrElemPtrTypeRef(alloc, index, elem_ptr_ty_ref); | 11868 | const elem_ptr = try block.addPtrElemPtrTypeRef(alloc, index, elem_ptr_ty_ref); |
| 11875 | _ = try block.addBinOp(.store, elem_ptr, arg); | 11869 | _ = try block.addBinOp(.store, elem_ptr, arg); |
| ... | @@ -11877,7 +11871,7 @@ fn zirArrayInit( | ... | @@ -11877,7 +11871,7 @@ fn zirArrayInit( |
| 11877 | return alloc; | 11871 | return alloc; |
| 11878 | } | 11872 | } |
| 11879 | | 11873 | |
| 11880 | return block.addAggregateInit(array_ty, elems); | 11874 | return block.addAggregateInit(array_ty, resolved_args); |
| 11881 | } | 11875 | } |
| 11882 | | 11876 | |
| 11883 | fn zirArrayInitAnon( | 11877 | fn zirArrayInitAnon( |