fix(javascript): preserve capture and property-key effect ownership

This commit is contained in:
morluto committed 2026-10-24 04:16:47 +08:00
1 parent b3433d0187
commit c6ac60acfe
7 files changed
+129 -7

No files matched your search

@@ -252,3 +252,30 @@ it("keeps same-receiver equality in an inert getter precise", () => {
`),
).toEqual({ status: "literal", value: 1 });
});
it("keeps intrinsic symbol keys separate from string overwrites without claiming complete inventory", () => {
expect(
returned(
`const state={value:1,[Symbol.toPrimitive](){return 0;}};return state.value;`,
),
).toEqual({ status: "literal", value: 1 });
const ir = analyzeJavaScriptSemantics(
`const state={value:1,[Symbol.toPrimitive](){return 0;}};`,
);
expect(ir.bindings.find(({ name }) => name === "state")?.value).toMatchObject(
{ status: "object", unknownProperties: true, omittedProperties: 1 },
);
expect(
returned(
`const Symbol={toPrimitive:"value"};const state={value:1,[Symbol.toPrimitive]:2};return state.value;`,
)?.status,
).toBe("unknown");
});
it("exposes shared fields when a constructed receiver is passed to an opaque call", () => {
expect(
returned(
`const shared={value:1};class Box{state=shared;} const box=new Box(); unknown(box);return shared.value;`,
)?.status,
).toBe("unknown");
});