mirror of
https://github.com/ziglang/zig.git
synced 2025-12-23 14:43:17 +00:00
Sema: fix coercion from [:0]T to [*c]T
This commit is contained in:
parent
0c1d8659c5
commit
6511afcfe0
@ -24615,8 +24615,9 @@ fn coerceExtra(
|
|||||||
else => break :p,
|
else => break :p,
|
||||||
}
|
}
|
||||||
if (inst_info.size == .Slice) {
|
if (inst_info.size == .Slice) {
|
||||||
if (dest_info.sentinel == null or inst_info.sentinel == null or
|
assert(dest_info.sentinel == null);
|
||||||
!dest_info.sentinel.?.eql(inst_info.sentinel.?, dest_info.pointee_type, sema.mod))
|
if (inst_info.sentinel == null or
|
||||||
|
!inst_info.sentinel.?.eql(Value.zero, dest_info.pointee_type, sema.mod))
|
||||||
break :p;
|
break :p;
|
||||||
|
|
||||||
const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty);
|
const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty);
|
||||||
|
|||||||
@ -1495,3 +1495,13 @@ test "cast typed undefined to int" {
|
|||||||
_ = b;
|
_ = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "implicit cast from [:0]T to [*c]T" {
|
||||||
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||||
|
|
||||||
|
var a: [:0]const u8 = "foo";
|
||||||
|
var b: [*c]const u8 = a;
|
||||||
|
var c = std.mem.span(b);
|
||||||
|
try expect(c.len == a.len);
|
||||||
|
try expect(c.ptr == a.ptr);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user