-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
track returned state in function body #14357
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
Conversation
For maintainers only:
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
@vankop Can you rebase? Thank you |
|
@@ -1799,6 +1805,7 @@ class JavascriptParser extends Parser { | |||
for (let index = 0, len = statements.length; index < len; index++) { | |||
const statement = statements[index]; | |||
this.walkStatement(statement); | |||
if (this.scope.terminated) break; |
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.
I like this solution, I'm only afraid of one thing, that some plugins could rely on it and rewrite something, and now we just will not handle them at all
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.
but this code is unreachable.. so I dont see a reason to waste cpu =)
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.
Yeah, I agree with you, I'm just worried that someone could use similar logic, but we can merge and look at feedback, It's not difficult to do a revert
Is there a npm package version or tarball I can use to test this? We have a massively distributed platform and bundle everything so at worst something stops working and at best we save some bytes in said bundles (: |
@alfaproject Are you about this Pr? |
Yes, is there an easy way I can test these changes easily? If it's just waiting for feedback from testers, that is |
@alfaproject You can install webpack from github, using |
I can confirm that there were no issues with these changes in our code base |
fix case when in try we throw and terminated=undefined for current scope
40a385a
to
9505321
Compare
TODO:
|
What kind of change does this PR introduce?
feature
closes #14347
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 feature design
Added 2 properties to parser current scope (
parser.scope
)terminated
marks that further parsing of nearestBlockStatement
should be terminated. Has 3 states'return'|'throw'|undefined
, whereundefined
= false,'return'|'throw'
types of terminationreturned
is inherited from childBlockStatement
(or terminate node in case ofif (true) return;
) to nearest parentBlockStatement
ifexecutedPath=true
executedPath
marks that current statement will be executed if nearestBlockStatement
will be reached, e.g.complex example
and one more 🔞
Notes regarding feature implementation
parser.hooks.terminate
looks kind of useless, not sure about it..TODO
drop skipped code. Any ideas how to do it better? we should do this from
terminated!=undefined
blocks tillterminated=undefined
blocks