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

Try/catch structure should be tree-shaken when try block is empty #3163

Closed
stephanedr opened this issue Oct 15, 2019 · 1 comment · Fixed by #3166
Closed

Try/catch structure should be tree-shaken when try block is empty #3163

stephanedr opened this issue Oct 15, 2019 · 1 comment · Fixed by #3166

Comments

@stephanedr
Copy link

  • Rollup Version: 1.24.0
  • Operating System (or Browser): Linux
  • Node Version: 10.16.3

How Do We Reproduce?

With tryCatchDeoptimization=false.

try {
}
catch (e) {
    console.log();
}

Expected Behavior

Completely removed, as no errors can be thrown (should also be removed with tryCatchDeoptimization=true).

Note that if a finally block exists, it must be preserved (without the finally keyword).

Actual Behavior

try {
}
catch (e) {
    console.log();
}
@stephanedr stephanedr changed the title Try/catch structure should be removed when try block is empty Try/catch structure should be tree-shaken when try block is empty Oct 15, 2019
@lukastaegert
Copy link
Member

lukastaegert commented Oct 16, 2019

Good point, as it turns out, there is never a reason to look for side-effects in the catch block when determining if the try-statement as a whole has side-effects. Improved in #3166.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants