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

Fix incomplete computed property deoptimization #3267

Merged
merged 1 commit into from Dec 1, 2019

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

Description

I am aware that #3266 already provides a fix for #3264 and I hope there is no ill thought from the author (the other fix in the PR is still welcome), but this PR will actually fix the root cause of the issue, which is that when the key of a computed property is later deoptimized, and the involved member expression had a deoptimized path, then ALL paths of the member expression need to be deoptimized (I know this may sound VERY confusing. I really hope to find some time soon to improve the names of the concepts around this).

So the result is that

const obj1 = {};
let prop = 'x';

updateProp();

obj1[prop] = true;

assert.strictEqual(obj1.y ? 'WORKING' : 'BUG', 'WORKING');

function updateProp() {
	prop = 'y';
}

is completely retained, while

const obj1 = {};
let prop = 'x';

obj1[prop] = true;

assert.strictEqual(obj1.y ? 'BUG' : 'WORKING', 'WORKING');

is correctly optimized to

assert.strictEqual( 'WORKING', 'WORKING');

@codecov
Copy link

codecov bot commented Dec 1, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3267      +/-   ##
==========================================
+ Coverage   92.83%   92.84%   +<.01%     
==========================================
  Files         170      170              
  Lines        5934     5941       +7     
  Branches     1793     1795       +2     
==========================================
+ Hits         5509     5516       +7     
  Misses        223      223              
  Partials      202      202
Impacted Files Coverage Δ
src/ast/nodes/ObjectExpression.ts 90.41% <ø> (ø) ⬆️
src/ast/nodes/MemberExpression.ts 95.61% <100%> (+0.28%) ⬆️

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 d7e3993...be25139. Read the comment docs.

@lukastaegert lukastaegert merged commit d5651be into master Dec 1, 2019
@lukastaegert lukastaegert deleted the gh-3264-computed-property-reassignment branch December 1, 2019 18:55
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.

Rollup removes correct code
1 participant