authorgravatar for codroid@gmail.comStevie Hryciw <codroid@gmail.com> 2022-12-14 15:51:09-08:00
committergravatar for codroid@gmail.comStevie Hryciw <codroid@gmail.com> 2022-12-15 00:56:27-08:00
log35750cd54f41477f25c77b8c44a220b57b40fd60
treef45745e61685f6dfc9db6610e2cd291d58136f50
parente57e835904d54b236cbaf0eedf5b8cea90a94542

Resolve lazy value before comparing


1 files changed, 4 insertions(+), 0 deletions(-)

src/Sema.zig+4
......@@ -28462,10 +28462,12 @@ fn cmpNumeric(
2846228462 if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| {
2846328463 // Compare ints: const vs. undefined (or vice versa)
2846428464 if (!lhs_val.isUndef() and (lhs_ty.isInt() or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt() and rhs_val.isUndef()) {
28465 try sema.resolveLazyValue(lhs_val);
2846528466 if (sema.compareIntsOnlyPossibleResult(target, lhs_val, op, rhs_ty)) |res| {
2846628467 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
2846728468 }
2846828469 } else if (!rhs_val.isUndef() and (rhs_ty.isInt() or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt() and lhs_val.isUndef()) {
28470 try sema.resolveLazyValue(rhs_val);
2846928471 if (sema.compareIntsOnlyPossibleResult(target, rhs_val, op.reverse(), lhs_ty)) |res| {
2847028472 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
2847128473 }
......@@ -28489,6 +28491,7 @@ fn cmpNumeric(
2848928491 } else {
2849028492 if (!lhs_val.isUndef() and (lhs_ty.isInt() or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt()) {
2849128493 // Compare ints: const vs. var
28494 try sema.resolveLazyValue(lhs_val);
2849228495 if (sema.compareIntsOnlyPossibleResult(target, lhs_val, op, rhs_ty)) |res| {
2849328496 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
2849428497 }
......@@ -28499,6 +28502,7 @@ fn cmpNumeric(
2849928502 if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| {
2850028503 if (!rhs_val.isUndef() and (rhs_ty.isInt() or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt()) {
2850128504 // Compare ints: var vs. const
28505 try sema.resolveLazyValue(rhs_val);
2850228506 if (sema.compareIntsOnlyPossibleResult(target, rhs_val, op.reverse(), lhs_ty)) |res| {
2850328507 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
2850428508 }