aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorriverbl <94326797+riverbl@users.noreply.github.com>2021-12-27 22:52:56 +0000
committerVeikka Tuominen <git@vexu.eu>2022-01-29 18:12:28 +0200
commit3c53667db8d44777c2fbceaf3c6d3a22a6c9caad (patch)
treeac459f5fcfabd49454dfa19c6e302b75d3fadb77 /src/value.zig
parent54634991a2b9767d20725b20a2c273b6db60a825 (diff)
downloadzig-3c53667db8d44777c2fbceaf3c6d3a22a6c9caad.tar.gz
zig-3c53667db8d44777c2fbceaf3c6d3a22a6c9caad.zip
stage2: fix bug where performing wrapping or saturating arithmetic or saturating left shift on type comptime_int executed unreachable code
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig
index faf4f38e80..df1531533b 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -2275,6 +2275,10 @@ pub const Value = extern union {
) !Value {
if (lhs.isUndef() or rhs.isUndef()) return Value.initTag(.undef);
+ if (ty.zigTypeTag() == .ComptimeInt) {
+ return intAdd(lhs, rhs, arena);
+ }
+
if (ty.isAnyFloat()) {
return floatAdd(lhs, rhs, ty, arena);
}
@@ -2361,6 +2365,10 @@ pub const Value = extern union {
) !Value {
if (lhs.isUndef() or rhs.isUndef()) return Value.initTag(.undef);
+ if (ty.zigTypeTag() == .ComptimeInt) {
+ return intSub(lhs, rhs, arena);
+ }
+
if (ty.isAnyFloat()) {
return floatSub(lhs, rhs, ty, arena);
}
@@ -2440,6 +2448,10 @@ pub const Value = extern union {
) !Value {
if (lhs.isUndef() or rhs.isUndef()) return Value.initTag(.undef);
+ if (ty.zigTypeTag() == .ComptimeInt) {
+ return intMul(lhs, rhs, arena);
+ }
+
if (ty.isAnyFloat()) {
return floatMul(lhs, rhs, ty, arena);
}