track returned state in function body#14357
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 |
|
| 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.
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.
but this code is unreachable.. so I dont see a reason to waste cpu =)
There was a problem hiding this comment.
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)terminatedmarks that further parsing of nearestBlockStatementshould be terminated. Has 3 states'return'|'throw'|undefined, whereundefined= false,'return'|'throw'types of terminationreturnedis inherited from childBlockStatement(or terminate node in case ofif (true) return;) to nearest parentBlockStatementifexecutedPath=trueexecutedPathmarks that current statement will be executed if nearestBlockStatementwill be reached, e.g.complex example
and one more 🔞
Notes regarding feature implementation
parser.hooks.terminatelooks kind of useless, not sure about it..TODO
drop skipped code. Any ideas how to do it better? we should do this from
terminated!=undefinedblocks tillterminated=undefinedblocks