Make sure the initializer of hoisted variables is deoptimized#4149
Merged
lukastaegert merged 3 commits intomasterfrom Jun 25, 2021
Merged
Make sure the initializer of hoisted variables is deoptimized#4149lukastaegert merged 3 commits intomasterfrom
lukastaegert merged 3 commits intomasterfrom
Conversation
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#gh-4147-deoptimize-hoisted-varsor load it into the REPL: |
Codecov Report
@@ Coverage Diff @@
## master #4149 +/- ##
=======================================
Coverage 98.28% 98.28%
=======================================
Files 201 201
Lines 7116 7118 +2
Branches 2084 2084
=======================================
+ Hits 6994 6996 +2
Misses 58 58
Partials 64 64
Continue to review full report at Codecov.
|
794de34 to
15695cb
Compare
9 tasks
lukastaegert
added a commit
that referenced
this pull request
Jul 7, 2021
* Fix var/const/let variable use before declaration * Also retains TDZ violations present in input * Enabled by default when treeshake is active * Low overhead - uses existing treeshaking simulated execution to mark declarations as reached * successfully run tests from #4149 without treeshake.correctVarBeforeDeclaration * Fix pattern handling * Handle TDZ class access * Improve field name * Fix TDZ caching * Only include entry point exports after first treeshaking pass * No longer make TDZ var access a side effect but treat as unknown value * Remove special logic for TDZ var assignments * Improve self-reference in declaration handling * Deprecate treeshake.correctVarValueBeforeDeclaration * Make deprecation non-active until next major version * Undeprecate correctVarValueBeforeDeclaration * Fix deoptimization regression for call expressions * Improve coverage Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #4147
Description
There was already a logic to deoptimize
varvariables that are defined in nested scopes. This logic deoptimized the value of such variables but forgot to also deoptimize the initializer of those variables. It also deoptimizes initializers when vars are deoptimized viatreeshake.correctVarValueBeforeDeclaration.While this is a bug fix, it may prove interesting to see if #4148 will offer a way to handle these things differently. This should not prevent release, however.