File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -803,6 +803,7 @@ const InstTracking = struct {
803
803
remaining_reg = tracked_reg;
804
804
};
805
805
assert(found_reg);
806
+ if (tracking.long == .none) tracking.long = tracking.short;
806
807
tracking.short = switch (remaining_reg) {
807
808
.none => .{ .dead = function.scope_generation },
808
809
else => .{ .register = remaining_reg },
Original file line number Diff line number Diff line change @@ -1079,3 +1079,17 @@ test "sentinel expression in slice operation has result type" {
1079
1079
comptime assert (slice [0 ] == 1 );
1080
1080
comptime assert (slice [1 ] == 2 );
1081
1081
}
1082
+
1083
+ test "conditionally return second argument slice" {
1084
+ if (builtin .zig_backend == .stage2_spirv ) return error .SkipZigTest ;
1085
+
1086
+ const S = struct {
1087
+ fn foo (cond : bool , slice : []const u8 ) []const u8 {
1088
+ if (cond ) return slice ;
1089
+ return &.{};
1090
+ }
1091
+ };
1092
+
1093
+ try expectEqualStrings ("" , S .foo (false , "false" ));
1094
+ try expectEqualStrings ("true" , S .foo (true , "true" ));
1095
+ }
You can’t perform that action at this time.
0 commit comments