Affects Version/s: None
Fix Version/s: None
Patch:Code and Test
Would expect both of these to return NaN but first does not:
Cause: Here we are dividing a double by a long. In the first case, this is parsed as divide(Object, long) which then calls divide(Object, Object), which throws ArithmeticException if the second arg is 0 (regardless of the first arg).
In the second case it's parsed as divide(double, long) which just relies on Java to properly upcast the primitive long to a double to do the divide.
Note that making this call with 2 doubles does return NaN:
or type hinting x to a double works as well:
Proposed: Add checks in divide(Object, Object) to check whether x is NaN and instead return NaN.
Prescreened by: Alex Miller