Skip to content

Commit 41284a3

Browse files
committed
allow implicit cast from *[N]T to ?[*]T
1 parent 0a918aa commit 41284a3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ir.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10708,7 +10708,14 @@ 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
IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, wanted_child_type);
10713+
=======
10714+
IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_child_type, value);
10715+
if (type_is_invalid(cast1->value.type))
10716+
return ira->codegen->invalid_instruction;
10717+
10718+
>>>>>>> allow implicit cast from *[N]T to ?[*]T
1071210719
return ir_analyze_maybe_wrap(ira, source_instr, cast1, wanted_type);
1071310720
}
1071410721
}

test/cases/cast.zig

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

493493
x = &y;
494-
assert(std.mem.eql(u16, x.?[0..4], y[0..4]));
495494
x.?[0] = 8;
496495
y[3] = 6;
497496
assert(std.mem.eql(u16, x.?[0..4], y[0..4]));

0 commit comments

Comments
 (0)