Description
Strict equality (===) with numbers returns an incorrect result when calling another function.
Steps to Reproduce
Run the following code:
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
public class Main {
public static void main(String[] args) {
String script = """
function funcA(a) { }
function funcB(a) {
if (a === 0) {
java.lang.System.out.println('true ' + a);
} else {
java.lang.System.out.println('false ' + a);
}
funcA(a);
}
(function funcC() {
funcB(0);
})();
""";
try (Context cx = Context.enter()) {
Scriptable scope = cx.initStandardObjects();
cx.evaluateString(scope, script, "example", 1, null);
}
}
}
Expected Output
true 0
Actual Output
false 0
Environment
JDK: openJDK 21
Rhino: 1.9.1
OS: Windows 11
Additional Notes
- If
funcA(a) is not called, the comparison works correctly.
- If
cx.setOptimizationLevel(-1) is called to run in interpreter mode, the comparison works correctly.
- If the comparison in the
if statement is written as 0 === a instead, the comparison works correctly.
Description
Strict equality (===) with numbers returns an incorrect result when calling another function.
Steps to Reproduce
Run the following code:
Expected Output
true 0
Actual Output
false 0
Environment
JDK: openJDK 21
Rhino: 1.9.1
OS: Windows 11
Additional Notes
funcA(a)is not called, the comparison works correctly.cx.setOptimizationLevel(-1)is called to run in interpreter mode, the comparison works correctly.ifstatement is written as0 === ainstead, the comparison works correctly.