diff --git a/src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts b/src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts index 3ad710588..ee4e602b1 100644 --- a/src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts +++ b/src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts @@ -307,22 +307,41 @@ describe("JavaScript semantic mutations through getter results (#1494)", () => { it("keeps a shared value known after an optional getter read or ordinary method read", () => { expect( - resultValue("const shared = { value: 1 }; const box = { get value() { return shared; } }; const alias = box?.value; return shared.value;"), + resultValue( + "const shared = { value: 1 }; const box = { get value() { return shared; } }; const alias = box?.value; return shared.value;", + ), ).toEqual({ status: "literal", value: 1 }); expect( - resultValue("const shared = { value: 1 }; const box = { value() { return shared; } }; const alias = box.value; return shared.value;"), + resultValue( + "const shared = { value: 1 }; const box = { value() { return shared; } }; const alias = box.value; return shared.value;", + ), ).toEqual({ status: "literal", value: 1 }); }); }); it.each([ - ["instance getter assignment", "const shared = { value: 1 }; class Box { get value() { return shared; } } const box = new Box(); box.value = {}; return shared.value;"], - ["instance getter deletion", "const shared = { value: 1 }; class Box { get value() { return shared; } } const box = new Box(); delete box.value; return shared.value;"], - ["static getter assignment", "const shared = { value: 1 }; class Box { static get value() { return shared; } } Box.value = {}; return shared.value;"], - ["static getter deletion", "const shared = { value: 1 }; class Box { static get value() { return shared; } } delete Box.value; return shared.value;"], -])("does not follow a class getter for direct property replacement or deletion (%s)", (_name, body) => { - expect(resultValue(body)).toEqual({ status: "literal", value: 1 }); -}); + [ + "instance getter assignment", + "const shared = { value: 1 }; class Box { get value() { return shared; } } const box = new Box(); box.value = {}; return shared.value;", + ], + [ + "instance getter deletion", + "const shared = { value: 1 }; class Box { get value() { return shared; } } const box = new Box(); delete box.value; return shared.value;", + ], + [ + "static getter assignment", + "const shared = { value: 1 }; class Box { static get value() { return shared; } } Box.value = {}; return shared.value;", + ], + [ + "static getter deletion", + "const shared = { value: 1 }; class Box { static get value() { return shared; } } delete Box.value; return shared.value;", + ], +])( + "does not follow a class getter for direct property replacement or deletion (%s)", + (_name, body) => { + expect(resultValue(body)).toEqual({ status: "literal", value: 1 }); + }, +); describe("JavaScript semantic values after mutable references escape", () => { it("preserves copied scalar slots while invalidating shared children of an escaped object spread", () => {