Files
ladybird/Tests/LibJS/Bytecode/input/invalid-lhs-forin-no-dead-code.js
Andreas Kling 176a618fce LibJS: Don't emit dead code after Throw for invalid LHS expressions
When the left-hand side of an assignment, update, or for-in loop is
invalid (e.g. `foo() = "bar"`), the bytecode generator emits a Throw
instruction. Previously, it would also create a dead basic block after
the Throw, resulting in unreachable instructions in the output.

Fix this by returning early from the relevant codegen paths after
emitting the Throw, and by guarding for-in/for-of body generation
with an is_current_block_terminated() check.
2026-03-01 21:20:54 +01:00

7 lines
156 B
JavaScript

// Test that for-in with an invalid LHS (like a call expression)
// does NOT emit dead code after the Throw instruction.
function f() {}
for (f() in []);