-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with coercion to boolean in legacy versions #1402
Comments
I don't get an error when I execute this code. If I try to evaluate |
Oh, I see. It only throws the TypeError for |
So, the actual difference in behavior appears to be that |
Yes, it's this snippet in if (Context.getContext().isVersionECMA1()) {
// pure ECMA
return true;
}
// ECMA extension
val = ((Scriptable) val).getDefaultValue(BooleanClass);
if ((val instanceof Scriptable) && !isSymbol(val))
throw errorWithClassName("msg.primitive.expected", val);
continue; |
I do not believe this is a regression. See comments on #1403 |
In legacy versions of the engine (< 1.3), Rhino does some special things for booleans and arrays; in particular:
This behavior does not happen in more recent version of the engine, but as ServiceNow we still have some scripts that rely on the legacy version of the engine. In particular, we have some code that throws an error, and that can be simplified to this:
This throws an error:
I'll be opening a PR to fix this.
The text was updated successfully, but these errors were encountered: