| author | |
| committer | |
| log | 6511afcfe090f26345873e7e8db3ae301f8a18a7 |
| tree | 5b5284adcd5445737bef0b17021651dab6d95cb1 |
| parent | 0c1d8659c51d9544fb8d5de7481e750149c262ae |
2 files changed, 13 insertions(+), 2 deletions(-)
src/Sema.zig+3-2| ... | @@ -24615,8 +24615,9 @@ fn coerceExtra( | ... | @@ -24615,8 +24615,9 @@ fn coerceExtra( |
| 24615 | else => break :p, | 24615 | else => break :p, |
| 24616 | } | 24616 | } |
| 24617 | if (inst_info.size == .Slice) { | 24617 | if (inst_info.size == .Slice) { |
| 24618 | if (dest_info.sentinel == null or inst_info.sentinel == null or | 24618 | assert(dest_info.sentinel == null); |
| 24619 | !dest_info.sentinel.?.eql(inst_info.sentinel.?, dest_info.pointee_type, sema.mod)) | 24619 | if (inst_info.sentinel == null or |
| 24620 | !inst_info.sentinel.?.eql(Value.zero, dest_info.pointee_type, sema.mod)) | ||
| 24620 | break :p; | 24621 | break :p; |
| 24621 | 24622 | ||
| 24622 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); | 24623 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); |
test/behavior/cast.zig+10| ... | @@ -1495,3 +1495,13 @@ test "cast typed undefined to int" { | ... | @@ -1495,3 +1495,13 @@ test "cast typed undefined to int" { |
| 1495 | _ = b; | 1495 | _ = b; |
| 1496 | } | 1496 | } |
| 1497 | } | 1497 | } |
| 1498 | |||
| 1499 | test "implicit cast from [:0]T to [*c]T" { | ||
| 1500 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 1501 | |||
| 1502 | var a: [:0]const u8 = "foo"; | ||
| 1503 | var b: [*c]const u8 = a; | ||
| 1504 | var c = std.mem.span(b); | ||
| 1505 | try expect(c.len == a.len); | ||
| 1506 | try expect(c.ptr == a.ptr); | ||
| 1507 | } |