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

Handle optional control flow in labeled statements, remove unused labels #3170

merged 5 commits into from Oct 18, 2019


Copy link

@lukastaegert lukastaegert commented Oct 18, 2019

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:
Resolves #3168


The original PR to handle tree-shaking after break/return/throw did not consider that of course, labeled break statements are a means of conditional control flow so that here:

code after the labeled statement CAN be executed even though the labeled statement ends with an error. Incidentally, fixing this made the logic much simpler in some places as we no longer need to track individual labels when tracking broken control flow but can treat labeled break and continue identical to return and throw as all of those will be reset by a surrounding labeled statement.

UNLESS of course there is no included labeled break or continue inside the labeled statement. To that end, we track which labels are actually used and remove the ones that are unused.

Copy link

codecov bot commented Oct 18, 2019

Codecov Report

Merging #3170 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3170      +/-   ##
+ Coverage   90.17%   90.18%   +<.01%     
  Files         165      165              
  Lines        5896     5902       +6     
  Branches     1794     1795       +1     
+ Hits         5317     5323       +6     
  Misses        350      350              
  Partials      229      229
Impacted Files Coverage Δ
src/ast/nodes/WhileStatement.ts 100% <100%> (ø) ⬆️
src/ast/nodes/ThrowStatement.ts 100% <100%> (ø) ⬆️
src/ast/nodes/SwitchCase.ts 100% <100%> (ø) ⬆️
src/ast/nodes/shared/FunctionNode.ts 100% <100%> (ø) ⬆️
src/ast/nodes/TryStatement.ts 100% <100%> (ø) ⬆️
src/ast/ExecutionContext.ts 100% <100%> (ø) ⬆️
src/ast/nodes/BlockStatement.ts 100% <100%> (ø) ⬆️
src/ast/nodes/ArrowFunctionExpression.ts 100% <100%> (ø) ⬆️
src/ast/nodes/ForStatement.ts 100% <100%> (ø) ⬆️
src/ast/nodes/ContinueStatement.ts 100% <100%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 836a106...50957a6. Read the comment docs.

# Conflicts:
#	src/ast/nodes/BreakStatement.ts
#	src/ast/nodes/ContinueStatement.ts
#	src/ast/nodes/DoWhileStatement.ts
#	src/ast/nodes/ForInStatement.ts
#	src/ast/nodes/ForStatement.ts
#	src/ast/nodes/SwitchStatement.ts
#	src/ast/nodes/WhileStatement.ts
@lukastaegert lukastaegert merged commit 121a7f4 into master Oct 18, 2019
7 checks passed
@lukastaegert lukastaegert deleted the labeled-statement-errors branch Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Treeshaking Removes Critical React DOM Code
1 participant