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
add guards support in JavascriptParser #15497
base: main
Are you sure you want to change the base?
Conversation
For maintainers only:
|
6ea8dfa
to
967da80
Compare
01cf4ba
to
d9bd4ba
Compare
Hey guys, any updates? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, because will be great to add more tests cases, I’m very afraid of regression, quite a serious change
@alexander-akait fixed |
@vankop Looks like we don't have |
optional chaining is not supported here.. in general we dont support optional chaining in import specifiers now as I remember, we just opt out optimizations. e.g.
|
I guess same for computed part of members expression like |
What kind of change does this PR introduce?
feature
closes #14814
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
no
What needs to be documented once your changes are merged?
nothing
** notes regarding design **
add in
parser.scope
parser.scope.guards
/parser.scope.inGuardPosition
termins:
guard
- chain of ids that is safe to use ( is truthy ) in currentparser.scope
in guard position
- any possibleguard
( chain of ids ) could be added toparser.scope.guards
, this means that thisguard
will be safe to use in current and all children parser scopes. e.g.&&
logical expression:also 2 binary expressions could be guard position:
x in y
/x != y ( when x falsy )
lets assume that
y
is import specifier then:also this could work with several guards positions, e.g. complex example: