Skip to content
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

A FunctionExpression/Method/Getter/Setter may capture its own name #23

Closed
Yoric opened this issue Feb 15, 2018 · 3 comments
Closed

A FunctionExpression/Method/Getter/Setter may capture its own name #23

Yoric opened this issue Feb 15, 2018 · 3 comments
Assignees

Comments

@Yoric
Copy link
Collaborator

Yoric commented Feb 15, 2018

The following snippet demonstrate how the name of a FunctionExpression can be captured:

let a = function f() {
  return function g() {
    return f;
  }
};
let b = a()(); // This is `f`

The same technique would probably work for Method, Getter, Setter.

For the moment, we have nowhere to store this information.

@syg
Copy link
Collaborator

syg commented Apr 4, 2018

I think this is only a bug for named FunctionExpressions. FunctionDeclarations' names are treated as bindings in the enclosing scope. Method, Getter, and Setter can't be recursively called like that, since they don't make a binding.

syg added a commit that referenced this issue Apr 4, 2018
@syg syg closed this as completed Apr 4, 2018
@Yoric
Copy link
Collaborator Author

Yoric commented Apr 4, 2018

So, if I read this correctly, we store the information in the parameterScope, right? This would probably deserve a comment in the webidl section.

@syg
Copy link
Collaborator

syg commented Apr 4, 2018

So, if I read this correctly, we store the information in the parameterScope, right? This would probably deserve a comment in the webidl section.

That's right, and it's mainly because of how the declared names are checked. AssertedParameterScopes' declared names are checked with the BoundNames static semantics in ecma262, instead of VarDeclaredNames or LexicallyDeclaredNames. That happens to match what the Catch production's runtime semantics already does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants