mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
parent
24bfefa75e
commit
c71bb0f2b6
@ -803,6 +803,7 @@ const InstTracking = struct {
|
||||
remaining_reg = tracked_reg;
|
||||
};
|
||||
assert(found_reg);
|
||||
if (tracking.long == .none) tracking.long = tracking.short;
|
||||
tracking.short = switch (remaining_reg) {
|
||||
.none => .{ .dead = function.scope_generation },
|
||||
else => .{ .register = remaining_reg },
|
||||
|
||||
@ -1079,3 +1079,17 @@ test "sentinel expression in slice operation has result type" {
|
||||
comptime assert(slice[0] == 1);
|
||||
comptime assert(slice[1] == 2);
|
||||
}
|
||||
|
||||
test "conditionally return second argument slice" {
|
||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn foo(cond: bool, slice: []const u8) []const u8 {
|
||||
if (cond) return slice;
|
||||
return &.{};
|
||||
}
|
||||
};
|
||||
|
||||
try expectEqualStrings("", S.foo(false, "false"));
|
||||
try expectEqualStrings("true", S.foo(true, "true"));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user