aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-10-16 19:55:31 +0200
committerRobin Voetter <robin@voetter.nl>2021-10-17 20:33:04 +0200
commitd004ef2e5d315e102e5be93ba68443ea0877492c (patch)
tree0585c6b1cc8aab2a44f063d524f66b5befd89610 /src
parentfd838584bfdc5ef4fb57927bded9e34474bc59d3 (diff)
downloadzig-d004ef2e5d315e102e5be93ba68443ea0877492c.tar.gz
zig-d004ef2e5d315e102e5be93ba68443ea0877492c.zip
stage2: make zirBoolNot return undefined when argument is undefined
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index b9c296bd4b..79469e2eec 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -8271,12 +8271,13 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
const bool_type = Type.initTag(.bool);
const operand = try sema.coerce(block, bool_type, uncasted_operand, operand_src);
- if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {
- if (val.toBool()) {
- return Air.Inst.Ref.bool_false;
- } else {
- return Air.Inst.Ref.bool_true;
- }
+ if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
+ return if (val.isUndef())
+ sema.addConstUndef(bool_type)
+ else if (val.toBool())
+ Air.Inst.Ref.bool_false
+ else
+ Air.Inst.Ref.bool_true;
}
try sema.requireRuntimeBlock(block, src);
return block.addTyOp(.not, bool_type, operand);