aboutsummaryrefslogtreecommitdiff
path: root/src/Type.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2024-09-17 14:34:10 +0100
committerGitHub <noreply@github.com>2024-09-17 14:34:10 +0100
commit41330c96aebddbf26d8fdc0725e7483476175601 (patch)
tree15b108f8983affc4933d60d6b0eaf6e2c2db35ee /src/Type.zig
parent812557bfde3c577b5f00cb556201c71ad5ed6fa4 (diff)
parent4650e5b9fcaa74b724a51458f5cf8952f3c734de (diff)
downloadzig-41330c96aebddbf26d8fdc0725e7483476175601.tar.gz
zig-41330c96aebddbf26d8fdc0725e7483476175601.zip
Merge pull request #21428 from mlugg/compare-to-undef
Sema: return undefined on comparison of runtime value against undefined
Diffstat (limited to 'src/Type.zig')
-rw-r--r--src/Type.zig8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/Type.zig b/src/Type.zig
index 2048fc852b..0dfd12cb35 100644
--- a/src/Type.zig
+++ b/src/Type.zig
@@ -3040,8 +3040,7 @@ pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {
pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {
const zcu = pt.zcu;
const info = ty.intInfo(zcu);
- if (info.signedness == .unsigned) return pt.intValue(dest_ty, 0);
- if (info.bits == 0) return pt.intValue(dest_ty, -1);
+ if (info.signedness == .unsigned or info.bits == 0) return pt.intValue(dest_ty, 0);
if (std.math.cast(u6, info.bits - 1)) |shift| {
const n = @as(i64, std.math.minInt(i64)) >> (63 - shift);
@@ -3072,10 +3071,7 @@ pub fn maxIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {
const info = ty.intInfo(pt.zcu);
switch (info.bits) {
- 0 => return switch (info.signedness) {
- .signed => try pt.intValue(dest_ty, -1),
- .unsigned => try pt.intValue(dest_ty, 0),
- },
+ 0 => return pt.intValue(dest_ty, 0),
1 => return switch (info.signedness) {
.signed => try pt.intValue(dest_ty, 0),
.unsigned => try pt.intValue(dest_ty, 1),