Skip to content

Commit

Permalink
Fully deoptimize first level path when deoptimizing nested parameter …
Browse files Browse the repository at this point in the history
…paths (#5153)
  • Loading branch information
lukastaegert committed Sep 24, 2023
1 parent a1a89e7 commit 353e462
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast/variables/ParameterVariable.ts
Expand Up @@ -109,7 +109,7 @@ export default class ParameterVariable extends LocalVariable {
for (const entity of this.entitiesToBeDeoptimized) {
// We do not need a recursion tracker here as we already track whether
// this field is deoptimized
entity.deoptimizePath(path);
entity.deoptimizePath([key]);
}
if (key === UnknownKey) {
// save some memory
Expand Down
8 changes: 8 additions & 0 deletions test/function/samples/track-mutated-in-callback/_config.js
@@ -0,0 +1,8 @@
module.exports = defineTest({
description: 'tracks mutations of variables in callbacks passed to globals',
context: {
globalFunction(callback) {
callback(true);
}
}
});
10 changes: 10 additions & 0 deletions test/function/samples/track-mutated-in-callback/main.js
@@ -0,0 +1,10 @@
const createCallback = box => newValue => {
box[0] = newValue;
return box[0];
};

const box = [null];
const callback = createCallback(box);
globalFunction(callback);

assert.ok(box[0] ? true : false);

0 comments on commit 353e462

Please sign in to comment.