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

Restore labels after included try statement block #3871

Merged
merged 1 commit into from Nov 14, 2020

Conversation

lukastaegert
Copy link
Member

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 #3869

Description

This solves a tricky issue in the interplay of the default deoptimization of try-catch blocks, see #3869. Basically what was happening is that while during the first tree-shaking run, the break statement with the label was correctly tracked, it was not tracked during the second run as it was nested in a try statement. And try statements are only evaluated once.

This PR fixes this by caching the labels that are used inside a try statement for subsequent runs.

@rollup-bot
Copy link
Collaborator

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#gh-3869-incorrectly-pruned-conditional-catch

or load it into the REPL:
https://rollupjs.org/repl/?circleci=13481

@codecov
Copy link

codecov bot commented Nov 14, 2020

Codecov Report

Merging #3871 (6d0199e) into master (57c13b3) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3871   +/-   ##
=======================================
  Coverage   97.06%   97.07%           
=======================================
  Files         184      184           
  Lines        6517     6523    +6     
  Branches     1887     1889    +2     
=======================================
+ Hits         6326     6332    +6     
  Misses        101      101           
  Partials       90       90           
Impacted Files Coverage Δ
src/ast/nodes/TryStatement.ts 95.65% <100.00%> (+1.53%) ⬆️

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 d861c91...6d0199e. Read the comment docs.

@lukastaegert lukastaegert merged commit 1ec3c4f into master Nov 14, 2020
@lukastaegert lukastaegert deleted the gh-3869-incorrectly-pruned-conditional-catch branch November 14, 2020 14:07
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

Successfully merging this pull request may close these issues.

Variable assignment incorrectly pruned within catch clause
2 participants