Repository navigation
Commit 9640f7b
Stop emitting a modifier if that guards several statements
`inline` records how the node was written, and a rewrite invalidates it.
Replacing the single statement of `foo if bar` with several emitted
`a\nb if bar`, where only the last one stays guarded — the rest runs
unconditionally.
Phlex expands an element into three statements, so a component writing
`span(class: "x") { plain content } if flag` opened the tag and called
`content` even when `flag` was false, leaving the tag unclosed and
running a side effect that should not have happened. 41 failures across
an application's suite came from this, second only to the buffer being
hoisted out of a capture.
A modifier only reads as one when it guards exactly one statement, so
that is now the condition for emitting it.
The test builds the node by hand: Ruby cannot parse a modifier `if` with
more than one statement, so the shape only ever comes from a rewrite.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 303cd0c commit 9640f7b
2 files changed
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
587 | 592 | | |
588 | 593 | | |
589 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
570 | 595 | | |
571 | 596 | | |
572 | 597 | | |
| |||
0 commit comments