Skip to content

fix math/number inconsistency#343

Open
CodePsy-2001 wants to merge 2 commits into
es-meta:devfrom
CodePsy-2001:fix/math-number-inconsistency
Open

fix math/number inconsistency#343
CodePsy-2001 wants to merge 2 commits into
es-meta:devfrom
CodePsy-2001:fix/math-number-inconsistency

Conversation

@CodePsy-2001

Copy link
Copy Markdown

related issue: #338

Summary

Fix interpreter crashes when implementation-approximated math results become non-finite values such as Infinity or NaN.

The reported case was:

Math.pow.call(0, -0.1, -Number.MAX_VALUE);
Math.pow(2, Number.MAX_VALUE);
Math.exp(1000);
Math.expm1(1000);
Math.cosh(1000);
Math.sinh(1000);

This previously crashed because math.pow(...) could return Double.PositiveInfinity, which was then wrapped as Math(BigDecimal). BigDecimal cannot represent infinity.

Changes

  • Preserve non-finite results from mathematical approximation paths.
  • Convert extended mathematical infinities through [approx-number].
  • Avoid wrapping non-finite Double results as Math.
  • Add regression test.

EvalSmallTest passes with 109 tests.

Discussions

Changes to this PR could harm the intended code design of 'Interpreter.scala', which needs to be reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant