es-meta / esmeta

ECMAScript Specification (ECMA-262) Metalanguage
BSD 3-Clause "New" or "Revised" License
175 stars 12 forks source link

Add OddIntegralNumber #203

Closed taxor03 closed 5 months ago

taxor03 commented 5 months ago

This PR includes adding OddIntegralNumber to support following form of statement in spec:

If _exponent_ is an odd integral Number, return ...

So, we added some logics according to OddIntegralNumber but encountered an issue handling Infinity value. The issue is occurred in following code snippet in EConvert case in interpreter.scala:

case (Number(d), ToMath) => Math(d)

As the type of d value in this function is Double, d allows Infinity value (POS/NEG). However when we convert Double.NegativeInfinity into Math value, it throws error. This is because BigDecimal doesn't support Infinity value.

d01c2 commented 5 months ago

I've reviewed the code, and I have a concern regarding the handling of Infinity values in the context of the statement you've mentioned.

In the Compiler.scala you've modified, the code proceeds with the modulo operation and determines if the value is odd. However, based on the current implementation in Compiler.scala, it seems that the logic doesn't explicitly handle the case where _exponent_ is Infinity.

Considering that Infinity is not a finite value and the modulo operation may not be well-defined in this context, I suggest modifying the Compiler.scala to explicitly check for Infinity and handle it accordingly. In this way, we can ensure that the code behaves as expected even when dealing with non-finite values.

d01c2 commented 5 months ago

LGTM! 👍🏻