diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-06-26 17:47:32 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-26 18:46:25 -0700 |
| commit | 9343c31c3879514c890c9bfa2a1cd1a1f222ed6d (patch) | |
| tree | 371a2fd2694adde2be6579563448e28e8facbfa5 /test/behavior/maximum_minimum.zig | |
| parent | 6bd54793060191ffce2c7492a90a40a30f9e2a1d (diff) | |
| download | zig-9343c31c3879514c890c9bfa2a1cd1a1f222ed6d.tar.gz zig-9343c31c3879514c890c9bfa2a1cd1a1f222ed6d.zip | |
Sema: fix `@min`/`@max` type resolution with all runtime args
Closes #16229
Diffstat (limited to 'test/behavior/maximum_minimum.zig')
| -rw-r--r-- | test/behavior/maximum_minimum.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/behavior/maximum_minimum.zig b/test/behavior/maximum_minimum.zig index 8d1153638d..0844cdd282 100644 --- a/test/behavior/maximum_minimum.zig +++ b/test/behavior/maximum_minimum.zig @@ -295,3 +295,17 @@ test "@min/@max notices bounds from vector types when element of comptime-known try expectEqual(@as(u32, 1_000_000), max[0]); // Cannot assert values at index 1 as one was undefined } + +test "@min/@max of signed and unsigned runtime integers" { + var x: i32 = -1; + var y: u31 = 1; + + const min = @min(x, y); + const max = @max(x, y); + + comptime assert(@TypeOf(min) == i32); + comptime assert(@TypeOf(max) == u31); + + try expectEqual(x, @min(x, y)); + try expectEqual(y, @max(x, y)); +} |
