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

LeftHandSideExpression of Assignment Expression can be a MemberExpression as well. #77

Closed
skepticfx opened this issue Aug 28, 2015 · 2 comments

Comments

@skepticfx
Copy link

I feel there is a small bug when walking the AST for AssignmentExpression, where the LeftHandSideExpression can be a MemberExpression as well in addition to Pattern.

Currently, the code only considers the Pattern type: https://github.com/estools/escope/blob/master/src/referencer.js#L460

Hence, a valid MemberExpression assignment like,

document.cookie = "key=value";

would not be stored as a proper WriteExpr in the Reference object. Rather there would be one referenece for document with a Flag of 1(READ).

Such assignment expressions are alteast very common in browser JavaScript code and a fix would be great. I know the code also, references something similar in the comments: https://github.com/estools/escope/blob/master/src/referencer.js#L98

If its considered a bug, any tips on how to fix this would be greatly appreciated, since I can work on a PR.

@mysticatea
Copy link
Contributor

This is a not bug.
Currently, escope does not support property references.

document.cookie = "key=value";

In this case, a reading reference of document is needed. It's correct. If document is null, we see a null reference access error.
If there is a writing property reference of document.cookie additionally, it's very useful.

However, it probably is a breaking change.

Related: #41

@skepticfx
Copy link
Author

I see! Thanks for the explanation. Appreciate it!

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

No branches or pull requests

2 participants