ReviewOS

home-lang/home

Transpiler: avoid duplicating unused ternary branches with comma tests

#577
Closed chris opened this 10 days ago ·
10 days ago

Follow-up to #66 from the unchanged pinned Bun transpiler corpus at source pin 4982b91e3702094330f3be3883354c52b8c01323.

For (f(), g()) ? 1 : h();, Home currently emits (f(), g() || h()) || h();, duplicating the false branch. Bun expects f(), g() || h();.

Port the upstream simplifier semantics so side effects and branch execution counts are preserved. Acceptance: the unchanged test does not duplicate the branch when simplifying an unused ternary with a comma test passes, with focused coverage for comma tests and side-effecting branches.

10 days ago

Resolved by 661d06dc87ceb3ee1af6643ff362d80947e8d33f. The left-associative AST rotation now returns the mutated comma expression immediately, matching upstream behavior and preventing the false/true branch from being wrapped and executed twice. The unchanged focused case passes (1/1), including both || and && forms.

Sign in to comment on this issue.