fix: correct #line directives for block constructs (GH #306)#416
Open
toddr-bot wants to merge 1 commit into
Open
fix: correct #line directives for block constructs (GH #306)#416toddr-bot wants to merge 1 commit into
toddr-bot wants to merge 1 commit into
Conversation
…cts (GH #306) Block directives (IF, FOREACH, WHILE, TRY, SWITCH, WRAPPER, FILTER, etc.) that span multiple lines were getting #line directives pointing to the END tag line instead of the opening tag line. This caused incorrect file/line info in error messages from compiled templates. Root cause: the chunk grammar rule called location() after the entire block was parsed, at which point the parser's line counter had advanced to the END tag. Fix: each block directive rule now saves the opening tag's line number via _block_start_line, and the chunk rule uses it. The ';' token value now carries the line number from its source tag, enabling accurate line tracking for both multi-tag and single-tag block directives. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
Recreated from #350 (auto-closed when the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#linedirectives in compiled templates for block directives (IF, FOREACH, WHILE, TRY, SWITCH, WRAPPER, FILTER, etc.);token value now carries the source line number. Each block directive grammar rule saves the opening tag's line via_block_start_line, which thechunkrule uses instead of the parser's current (post-END) line counter.Testing
t/compile_line.tcovering IF, FOREACH, WHILE, TRY, SWITCH, UNLESS, WRAPPER, FILTER, nested blocks, and single-tag blocksCloses #306
🤖 Generated with Claude Code