-
Notifications
You must be signed in to change notification settings - Fork 784
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
Range for object literal shorthand methods doesn't include params #1029
Labels
Comments
This was referenced Feb 14, 2015
btmills
added a commit
to btmills/esprima
that referenced
this issue
Feb 14, 2015
Previously, the range and loc for get, set, and shorthand methods inside object literal properties included only the method body, meaning a method's parameters were outside the range of their parent `FunctionExpression` node. This was happening because the `FunctionExpression` node wasn't being created until `parsePropertyFunction` was called, by which point the method's parameters had already been parsed. This PR solves the issue by creating the `FunctionExpression` node as soon as it determines that the property is a get, set, or shorthand method, then passing the node into `parsePropertyFunction`. Closes jquery#1029
I took a look at property setter and it seems to have the same problem: #1040. |
btmills
added a commit
to btmills/esprima
that referenced
this issue
Feb 16, 2015
Previously, the range and loc for get, set, and shorthand methods inside object literal properties included only the method body, meaning a method's parameters were outside the range of their parent `FunctionExpression` node. This was happening because the `FunctionExpression` node wasn't being created until `parsePropertyFunction` was called, by which point the method's parameters had already been parsed. This PR solves the issue by creating the `FunctionExpression` node as soon as it determines that the property is a get, set, or shorthand method, then passing the node into `parsePropertyFunction`. Closes jquery#1029 Closes jquery#1040
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What steps will reproduce the problem?
On a fresh checkout of the harmony branch:
What is the expected output?
I would expect the FunctionExpression's range to include the method's parameters as well as the body as in
(arg1) {}
.It makes sense that the method's name is not included, as that is the Property's key and does not belong to the FunctionExpression.
What do you see instead?
The FunctionExpression's range includes only the body,
{}
, leading to a scenario in which a traversal starting at the FunctionExpression, range 21-23, would reach the parameter, whose range, 15-19, lies outside that of its parent.(Migrated from https://code.google.com/p/esprima/issues/detail?id=625, as reported by @btmills)
The text was updated successfully, but these errors were encountered: