authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-16 19:55:31+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-17 20:33:04+02:00
logd004ef2e5d315e102e5be93ba68443ea0877492c
tree0585c6b1cc8aab2a44f063d524f66b5befd89610
parentfd838584bfdc5ef4fb57927bded9e34474bc59d3

stage2: make zirBoolNot return undefined when argument is undefined


1 files changed, 7 insertions(+), 6 deletions(-)

src/Sema.zig+7-6
......@@ -8271,12 +8271,13 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
82718271
82728272 const bool_type = Type.initTag(.bool);
82738273 const operand = try sema.coerce(block, bool_type, uncasted_operand, operand_src);
8274 if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {
8275 if (val.toBool()) {
8276 return Air.Inst.Ref.bool_false;
8277 } else {
8278 return Air.Inst.Ref.bool_true;
8279 }
8274 if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
8275 return if (val.isUndef())
8276 sema.addConstUndef(bool_type)
8277 else if (val.toBool())
8278 Air.Inst.Ref.bool_false
8279 else
8280 Air.Inst.Ref.bool_true;
82808281 }
82818282 try sema.requireRuntimeBlock(block, src);
82828283 return block.addTyOp(.not, bool_type, operand);