Repository navigation
parser/executor: rebase heredoc gather end line with token positions - #3680
Merged
Merged
Conversation
Token::heredoc_end_line records the physical line where the lexer
stopped gathering a here-document body. When a folded or reparsed
region shifted `position`/`end_position`/`logical_line` into the
ambient line space (source offsets, folded `{`/function bodies, eval
and trap boundaries, unclosed-compound regions), the gather end line
stayed at its fragment-relative value. The EOF gather warning then
printed under the wrong `line N:` prefix: `f() {\ncat <<EOF\nx`
warned at line 2 where GNU warns at line 3, and unclosed-compound EOF
errors could fall back to the fragment-local line.
Shift `heredoc_end_line` in lockstep at every rebase site:
- script_driver.rs run_source_impl_inner_body (line_offset)
- builtins/source/execution.rs run_source_groups (line_offset)
- trap_exec.rs caller_line eval splice + line_offset parse (2 sites)
- function_command.rs folded body re-lex (base - 1)
- function_calls.rs quoted function word (base_line - 1)
- parse_loop.rs unclosed_brace_eof_node inner region (brace_line - 1)
GNU owner: make_cmd.c gather line accounting — the warning reports
`line_number` once the gather stops at EOF (the physical end line,
rubash#1028 family); parse.y:6899 reports the same ambient space for
the unclosed-compound error.
Verified on macOS arm64 against GNU Bash 5.3.20:
`{ cat <<EOF\nx` -> `line 2` warning naming `at line 1`;
`f() {\ncat <<EOF\nx` -> `line 3` naming `at line 2`;
offset brace group (`x=1\n{\ncat <<EOF\nx`) -> `line 4` naming
`at line 3`. niubash gate slice run-heredoc: PASS (the remaining diff
turned out to be macOS bash 3.2 rewriting exported-function env
values in the harness, not a rubash divergence).
New pins: tests/issue3605_heredoc_end_line_rebase.rs (3 cases).
Refs #3605
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Nov 15, 2026
Merged
Member
Author
|
【WIN-AGENT-AUDIT】开工评论:机制已验证(分组路径 warn prefix base=line3 vs GNU line6,head 已修正一致),但所附钉的 3 个形状不走分组驱动路径,在未修复 base 上同样全绿 = 非判别钉。本轮续作只补一个判别测试( |
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:无(钉判别力缺口见上,作注记不作否决) 续作记录:本轮未落地(env 钩阻断,见上) 未跑/VOID 的腿:cargo fmt 全库(os error 206 环境限),以逐文件 rustfmt --check 替代 |
caomengxuan666
marked this pull request as ready for review
November 16, 2026 07:18
This was referenced Nov 16, 2026
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
Token::heredoc_end_linerecords the physical line where the lexer stopped gathering a here-document body. Every site that shifts a token'sposition/end_position/logical_lineinto the ambient line space (source offsets, folded{/function bodies, eval/trap boundaries, unclosed-compound regions) now shifts the gather end line in lockstep.Before this, a here-document that hit EOF inside a rebased region warned under the fragment-local line:
f() {\ncat <<EOF\nxprintedline 2: warning: here-document ...where GNU printsline 3. Six rebase sites updated (script_driver,builtins/source/execution,trap_exec×2,function_command,function_calls,parse_loop::unclosed_brace_eof_node).GNU owner:
make_cmd.cgather line accounting — the warning reportsline_numberonce the gather stops at EOF (the physical end line, #1028 family);parse.y:6899reports the same ambient space for the unclosed-compound error.Verification
{ cat <<EOF\nx→line 2warning namingat line 1;f() {\ncat <<EOF\nx→line 3namingat line 2;x=1\n{\ncat <<EOF\nx→line 4namingat line 3.run-heredoc: PASS (the last remaining diff was macOS/bin/bash3.2 rewriting exported-function env values inside the test harness — niubash-side infra, not a rubash divergence).tests/issue3605_heredoc_end_line_rebase.rs(3 cases).{-family unclosed-compound EOF errors reportlast_linewhere GNU reportslast_line + 1({ cat <<EOF\nx→ niuline 2, GNUline 3);(-family already correct.Refs #3605