fix(javascript): preserve primitive addition coercion (#666)

Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-06 16:17:55 +08:00
committed by GitHub
parent 1a24be574d
commit 94cc8475e0
2 changed files with 20 additions and 3 deletions
@@ -273,3 +273,20 @@ describe("JavaScript semantic analysis: dataflow 2", () => {
]);
});
});
describe("primitive addition values", () => {
it.each([
["true + 1", 2],
["null + 2", 2],
["false + true", 1],
['"x" + false', "xfalse"],
['null + "x"', "nullx"],
["3 + 4", 7],
])("recovers %s using primitive coercion", (expression, expected) => {
const ir = analyzeJavaScriptSemantics(`const answer = ${expression};`);
expect(topLevelBinding(ir, "answer").value).toEqual({
status: "literal",
value: expected,
});
});
});