-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Function name scope problem #354
Comments
Just found if I set the optimization level of the context to 0 or above, I can get the same result as Chrome. |
Sounds strange will have a look over the weekend |
Based on the link above, the example can be simplified: console.log("foo="+foo);
if (false) {
function foo(){ return 1; }
} |
It seems the declaration of 'foo' is removed here:
|
Maybe not. It seems the tree printed out is not quite complete. |
I found the key point. The function definition is skipped here in runtime. Apparently InterpretedFunction.hasFunctionNamed(name) does not do what its name implies. It returns false for functions declared with expression, returns true otherwise, event it's not a function at all. I changed InterpretedFunction.hasFunctionNamed to simply return a fixed true and then the script runs same with browsers. I don't see any other problem with that change but I might miss something else since I'm not familiar with Rhino. |
Hi @RuralHunter, |
Great and thanks as always. |
see #755 |
This code snippet:
In Chrome, the output is "f=undefined". In HtmlUnit, the output is "f=function(){}".
The text was updated successfully, but these errors were encountered: