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(...@@ -28462,10 +28462,12 @@ fn cmpNumeric(
28462 if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| {28462 if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| {
28463 // Compare ints: const vs. undefined (or vice versa)28463 // Compare ints: const vs. undefined (or vice versa)
28464 if (!lhs_val.isUndef() and (lhs_ty.isInt() or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt() and rhs_val.isUndef()) {28464 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);
28465 if (sema.compareIntsOnlyPossibleResult(target, lhs_val, op, rhs_ty)) |res| {28466 if (sema.compareIntsOnlyPossibleResult(target, lhs_val, op, rhs_ty)) |res| {
28466 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;28467 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
28467 }28468 }
28468 } else if (!rhs_val.isUndef() and (rhs_ty.isInt() or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt() and lhs_val.isUndef()) {28469 } 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);
28469 if (sema.compareIntsOnlyPossibleResult(target, rhs_val, op.reverse(), lhs_ty)) |res| {28471 if (sema.compareIntsOnlyPossibleResult(target, rhs_val, op.reverse(), lhs_ty)) |res| {
28470 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;28472 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
28471 }28473 }
...@@ -28489,6 +28491,7 @@ fn cmpNumeric(...@@ -28489,6 +28491,7 @@ fn cmpNumeric(
28489 } else {28491 } else {
28490 if (!lhs_val.isUndef() and (lhs_ty.isInt() or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt()) {28492 if (!lhs_val.isUndef() and (lhs_ty.isInt() or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt()) {
28491 // Compare ints: const vs. var28493 // Compare ints: const vs. var
28494 try sema.resolveLazyValue(lhs_val);
28492 if (sema.compareIntsOnlyPossibleResult(target, lhs_val, op, rhs_ty)) |res| {28495 if (sema.compareIntsOnlyPossibleResult(target, lhs_val, op, rhs_ty)) |res| {
28493 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;28496 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
28494 }28497 }
...@@ -28499,6 +28502,7 @@ fn cmpNumeric(...@@ -28499,6 +28502,7 @@ fn cmpNumeric(
28499 if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| {28502 if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| {
28500 if (!rhs_val.isUndef() and (rhs_ty.isInt() or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt()) {28503 if (!rhs_val.isUndef() and (rhs_ty.isInt() or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt()) {
28501 // Compare ints: var vs. const28504 // Compare ints: var vs. const
28505 try sema.resolveLazyValue(rhs_val);
28502 if (sema.compareIntsOnlyPossibleResult(target, rhs_val, op.reverse(), lhs_ty)) |res| {28506 if (sema.compareIntsOnlyPossibleResult(target, rhs_val, op.reverse(), lhs_ty)) |res| {
28503 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;28507 return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false;
28504 }28508 }