@@ -2623,10 +2623,9 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
26232623 // block so that codegen does not see it.
26242624 block.instructions.shrinkRetainingCapacity(block.instructions.items.len - 3);
26252625 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
2627- // `air_datas[ptr_inst].ty_pl.ty`, wouldn't it? Alas, that is almost correct,
2628- // except that the pointer is mutable and we need to make it constant here.
2629- air_datas[ptr_inst].ty_pl.ty = try sema.addType(final_ptr_ty);
2626+ // if bitcast ty ref needs to be made const, make_ptr_const
2627+ // ZIR handles it later, so we can just use the ty ref here.
2628+ air_datas[ptr_inst].ty_pl.ty = air_datas[bitcast_inst].ty_op.ty;
26302629
26312630 return;
26322631 }
@@ -11828,21 +11827,16 @@ fn zirArrayInit(
1182811827 });
1182911828 };
1183011829
11831- const elems = if (!is_sent)
11832- resolved_args
11833- else
11834- resolved_args[0 .. resolved_args.len - 1];
11835-
11836- const opt_runtime_src: ?LazySrcLoc = for (elems) |arg| {
11830+ const opt_runtime_src: ?LazySrcLoc = for (resolved_args) |arg| {
1183711831 const arg_src = src; // TODO better source location
1183811832 const comptime_known = try sema.isComptimeKnown(block, arg_src, arg);
1183911833 if (!comptime_known) break arg_src;
1184011834 } else null;
1184111835
1184211836 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);
1184411838
11845- for (elems ) |arg, i| {
11839+ for (resolved_args ) |arg, i| {
1184611840 // We checked that all args are comptime above.
1184711841 elem_vals[i] = (sema.resolveMaybeUndefVal(block, src, arg) catch unreachable).?;
1184811842 }
@@ -11869,15 +11863,15 @@ fn zirArrayInit(
1186911863 });
1187011864 const elem_ptr_ty_ref = try sema.addType(elem_ptr_ty);
1187111865
11872- for (elems ) |arg, i| {
11866+ for (resolved_args ) |arg, i| {
1187311867 const index = try sema.addIntUnsigned(Type.usize, i);
1187411868 const elem_ptr = try block.addPtrElemPtrTypeRef(alloc, index, elem_ptr_ty_ref);
1187511869 _ = try block.addBinOp(.store, elem_ptr, arg);
1187611870 }
1187711871 return alloc;
1187811872 }
1187911873
11880- return block.addAggregateInit(array_ty, elems );
11874+ return block.addAggregateInit(array_ty, resolved_args );
1188111875}
1188211876
1188311877fn zirArrayInitAnon(
0 commit comments