-
Notifications
You must be signed in to change notification settings - Fork 17
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
Scopes: support default parameter initializers #78
Comments
I think this could be supported with the current proposal by encoding two sibling scopes for each function: one containing only the parameters and with the location range of the parameter declarations and one containing parameters and local variables with the location range of the function's body. |
I'm not sure about sibling scopes, but we could handle it similar to how JS engines do this. (See this comment):
|
Right, and actually the documentation at MDN also suggests this (because it says the extra scope should be the parent of the function body's scope) and this is also more efficient (because we don't need to repeat the function parameters).
Actually I found that the extra scope is only created when it's absolutely necessary: when default initializers are used and one of the initializers references a variable that is redeclared in the function's body. |
I was wrong about this - it seems the extra scope is created when default initializers are used and there is a variable declaration in the body. Generally JS engines seem to omit scopes without bindings. |
I've added examples showing how this can be done using the current proposal. |
From MDN:
To support this we need to add some information for function scopes:
The text was updated successfully, but these errors were encountered: