File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -26201,6 +26201,10 @@ fn analyzeMinMax(
2620126201 .child = refined_scalar_ty.toIntern(),
2620226202 }) else refined_scalar_ty;
2620326203
26204+ if (try sema.typeHasOnePossibleValue(refined_ty)) |opv| {
26205+ return Air.internedToRef(opv.toIntern());
26206+ }
26207+
2620426208 if (!refined_ty.eql(unrefined_ty, zcu)) {
2620526209 // We've reduced the type - cast the result down
2620626210 return block.addTyOp(.intcast, refined_ty, cur_minmax.?);
Original file line number Diff line number Diff line change @@ -336,3 +336,17 @@ test "@min/@max of signed and unsigned runtime integers" {
336336 try expectEqual (x , @min (x , y ));
337337 try expectEqual (y , @max (x , y ));
338338}
339+
340+ test "@min resulting in u0" {
341+ if (builtin .zig_backend == .stage2_aarch64 ) return error .SkipZigTest ; // TODO
342+ if (builtin .zig_backend == .stage2_arm ) return error .SkipZigTest ; // TODO
343+ if (builtin .zig_backend == .stage2_sparc64 ) return error .SkipZigTest ; // TODO
344+
345+ const S = struct {
346+ fn min (a : u0 , b : u8 ) u8 {
347+ return @min (a , b );
348+ }
349+ };
350+ const x = S .min (0 , 1 );
351+ try expect (x == 0 );
352+ }
You can’t perform that action at this time.
0 commit comments