-
-
Notifications
You must be signed in to change notification settings - Fork 547
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 using functions when Strict option is enabled, since 3.0.26 #857
Comments
I think the curly brackets make the function block scoped function (at least in strict mode) and it will not be hoisted to outside scope, it's ES6 behavior. It seems that the function should be visible though for the block when it's only called inside of it. |
I think the problem is here: jint/Jint/Runtime/Interpreter/JintStatementList.cs Lines 114 to 144 in 546f1e8
If you'd like to implement the missing bits, a PR would be most welcome. |
Note that you can't necessarily compare with browser implementation in this - the ECMAScript spec defines different behavior for block level function declarations in browsers vs other ECMAScript implementations. ES6 strict mode in a browser will create both a block scoped and function scoped binding for the function. Outside a browser, things are simpler - the function will be block scoped (and thus not callable from outside the block) in both strict and non-strict mode. https://262.ecma-international.org/6.0/#sec-block-level-function-declarations-web-legacy-compatibility-semantics (ETA: that's just a clarification - the code in the example should til work as in the browser). |
@lahma we are not that familiar with all internals and caveats of JS. I would say that it would be saver if one of the Jint contributors could take a look. |
Hi
The following test passes in version 3.0.25 (and older), but started failing since 3.0.26
Note that if we remove from the script the curly brackets that start after
var i = doc;
then the test passes.Same if
Strict
option is disabled.The text was updated successfully, but these errors were encountered: