mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
parent
0f38558435
commit
fbe0ae4fd4
@ -34603,14 +34603,14 @@ fn resolvePeerTypesInner(
|
|||||||
}
|
}
|
||||||
// Clear existing sentinel
|
// Clear existing sentinel
|
||||||
ptr_info.sentinel = .none;
|
ptr_info.sentinel = .none;
|
||||||
switch (ip.indexToKey(ptr_info.child)) {
|
if (ptr_info.flags.size == .one) switch (ip.indexToKey(ptr_info.child)) {
|
||||||
.array_type => |array_type| ptr_info.child = (try pt.arrayType(.{
|
.array_type => |array_type| ptr_info.child = (try pt.arrayType(.{
|
||||||
.len = array_type.len,
|
.len = array_type.len,
|
||||||
.child = array_type.child,
|
.child = array_type.child,
|
||||||
.sentinel = .none,
|
.sentinel = .none,
|
||||||
})).toIntern(),
|
})).toIntern(),
|
||||||
else => {},
|
else => {},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
opt_ptr_info = ptr_info;
|
opt_ptr_info = ptr_info;
|
||||||
|
|||||||
@ -2649,3 +2649,19 @@ test "bitcast vector" {
|
|||||||
const bigsum: u32x8 = @bitCast(zerox32);
|
const bigsum: u32x8 = @bitCast(zerox32);
|
||||||
try std.testing.expectEqual(0, @reduce(.Add, bigsum));
|
try std.testing.expectEqual(0, @reduce(.Add, bigsum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "peer type resolution: slice of sentinel-terminated array" {
|
||||||
|
var f: bool = undefined;
|
||||||
|
f = false;
|
||||||
|
|
||||||
|
const a: [][2:0]u8 = &.{};
|
||||||
|
const b: []const [2:0]u8 = &.{.{ 10, 20 }};
|
||||||
|
|
||||||
|
const result = if (f) a else b;
|
||||||
|
|
||||||
|
comptime assert(@TypeOf(result) == []const [2:0]u8);
|
||||||
|
try expect(result.len == 1);
|
||||||
|
try expect(result[0].len == 2);
|
||||||
|
try expect(result[0][0] == 10);
|
||||||
|
try expect(result[0][1] == 20);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user