Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track mutations of elements pushed into arrays (#5352)
* Add test for dependency deoptimization * Deoptimize elements pushed into an array * Copy rollup types in tests to avoid temporary type issues
- Loading branch information
1 parent
c4ba8eb
commit f2ed658
Showing
5 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
3 changes: 3 additions & 0 deletions
3
test/function/samples/deoptimize-pushed-array-element/_config.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = defineTest({ | ||
description: 'deoptimizes elements pushed into an array' | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/function/samples/deoptimize-pushed-array-element/main.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let mutated1 = false; | ||
const state1 = { | ||
foo: undefined | ||
}; | ||
|
||
let mutated2 = false; | ||
const state2 = { | ||
foo: undefined | ||
}; | ||
|
||
const stack = []; | ||
stack.push(state1, state2); | ||
stack[0].foo = () => (mutated1 = true); | ||
stack.at(-1).foo = () => (mutated2 = true); | ||
|
||
state1.foo?.(); | ||
assert.ok(mutated1, '1'); | ||
|
||
state2.foo?.(); | ||
assert.ok(mutated2, '2'); | ||
|