Skip to content

Commit a95a992

Browse files
committed
call ir_resolve_ptr_of_array_to_slice instead of recursing
1 parent 41284a3 commit a95a992

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/ir.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10708,6 +10708,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1070810708
actual_type->data.pointer.child_type->data.array.child_type, source_node,
1070910709
!wanted_child_type->data.pointer.is_const).id == ConstCastResultIdOk)
1071010710
{
10711+
<<<<<<< HEAD
1071110712
<<<<<<< HEAD
1071210713
IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, wanted_child_type);
1071310714
=======
@@ -10716,6 +10717,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1071610717
return ira->codegen->invalid_instruction;
1071710718

1071810719
>>>>>>> allow implicit cast from *[N]T to ?[*]T
10720+
=======
10721+
IrInstruction *cast1 = ir_resolve_ptr_of_array_to_slice(ira, source_instr, value, wanted_child_type);
10722+
>>>>>>> call ir_resolve_ptr_of_array_to_slice instead of recursing
1071910723
return ir_analyze_maybe_wrap(ira, source_instr, cast1, wanted_type);
1072010724
}
1072110725
}

test/cases/cast.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ test "implicit cast from *[N]T to ?[*]T" {
491491
var y: [4]u16 = [4]u16 {0, 1, 2, 3};
492492

493493
x = &y;
494+
<<<<<<< HEAD
495+
=======
496+
assert(std.mem.eql(u16, x.?[0..4], y[0..4]));
497+
>>>>>>> call ir_resolve_ptr_of_array_to_slice instead of recursing
494498
x.?[0] = 8;
495499
y[3] = 6;
496500
assert(std.mem.eql(u16, x.?[0..4], y[0..4]));

0 commit comments

Comments
 (0)