Skip to content

rubash#3605 run-func: rebase end_position with position in line_offset paths - #3676

Merged
caomengxuan666 merged 2 commits into
masterfrom
devin/grouped-def-end-line
Nov 16, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
devin/grouped-def-end-line

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Fixes the run-func class-B item from #3605: a function NAME definition whose { sits on the following line reported an invalid identifier at the { line instead of the definition's parse-end (}) line.

Root cause. The line_offset rebase applied to pre-lexed tokens shifted position/column/logical_line but left end_position in the old line space. finish_compound_command stamps a compound's end_line from max(position, end_position) (src/parser/arithmetic_command.rs), so a folded { ... } token — which spans lines and is born with end_position == position — stamped the { line once a nonzero offset was applied (later groups on the grouped script driver). Fixed at all five rebase sites: run_source_impl (script_driver.rs), builtins/source execution, the eval and DEBUG-condition rebases (trap_exec.rs), and the comsub alias-splice rebase (function_calls.rs).

Trigger path. func5.sub takes the grouped driver because script_runs_foreign_text's textual markers match . inside its license comment (... FOR A PARTICULAR PURPOSE. See the). The def at lines 28–31 reported not a valid identifier at line 29 where GNU reports 31.

GNU anchor. execute_cmd.c:6289 execute_intern_function checks valid_function_word at EXECUTION time and yyerrors with the ambient line_number, which by then is the function_def's parse-END line.

Verified against GNU bash 5.3.20 via script files: }-line report on the fast path, the grouped driver, and func5.sub's full layout; niubash gate run-func PASS on macOS arm64. New regression file tests/issue3605_grouped_def_end_line.rs pins all three shapes.

Refs #3605

…t paths

The line_offset rebase in run_source_impl (and the matching rebases in
builtins/source, eval, debug-condition, and comsub alias-splice paths)
shifted position/column/logical_line but left end_position in the old
line space. finish_compound_command stamps a compound's end_line from
max(position, end_position) (arithmetic_command.rs), so a folded
'{ ... }' token — which spans lines and is born with
end_position == position — reported the '{' line once any nonzero
offset was applied (later groups on the grouped driver).

run-func's func5.sub takes the grouped path (script_runs_foreign_text
matches '. ' inside its license comment) and the def at lines 28-31
reported 'not a valid identifier' at line 29 (the '{') where GNU
reports 31 (the '}').

GNU anchor: execute_cmd.c:6289 execute_intern_function checks
valid_function_word at EXECUTION time and yyerror's with the ambient
line_number, which by then is the function_def's parse-END line.

Verified against GNU bash 5.3.20 (script files): '}'-line report on
fast path, grouped path, and func5.sub's full layout. New regression
file tests/issue3605_grouped_def_end_line.rs pins all three.

Refs #3605

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3676 第1轮 — 建议:PASS
head: 091a437 base(merge-base): 96802ca 文件: 5 个 +100/-0
关联 issue: #3605(open,核于 2026-11-16 — 追踪目录 issue,合并不关单)

机制核查:

  • 5 个重定基点(run_source_groups、comsub 拼接 function_calls、trap_exec eval/DEBUG 两处、run_source_impl line_offset)把 end_position 与 position 同空间位移 — finish_compound_command 的 max(position, end_position)(arithmetic_command.rs)此前把折叠 { ... } 的 end_line 钉回 { 行;位移后取到 } 行,对应 GNU execute_cmd.c execute_intern_function 在 execute 时以 ambient line_number(函数定义 parse-end 行)报 invalid identifier。机制贴合。
  • 无关改动:无;无桥接层。

腿:

  • 钉自跑:issue3605_grouped_def_end_line 3/3 绿
  • fail-first:base 上 1 passed / 2 failed,红名 = {issue3605_grouped_driver_def_reports_close_line, issue3605_grouped_driver_late_def_reports_close_line}(fast-path 形在 base 已正确)
  • lib 双边:head {issue2084_session_end_restores_host_process_state} / base 同 / 差集 {}(Windows 本机 flake,双侧相同)
  • -D warnings:lib+bins 0;钉 stem 编译 0
  • 卫生:PR 全部文件 rustfmt --check 0 diff(cargo fmt 全库本机 os error 206 不可用,逐文件替代)
  • CI:红 = 3 job 仅 issue2875 基线;census skipped
  • GNU 对照(WSL GNU bash 5.3.20 脚本文件,.audit-s6/probes/):function sys$read + { 下一行 → GNU/head line 5 一致;# comment . trailing 分组形 → line 5 一致;func5.sub 式三 def 序列 → line 15 一致

F 点:无

未跑/VOID 的腿:无

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 16, 2026 08:24
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3676 第1轮 — 建议:PASS(合入被冲突阻断,不合并)
head: 091a437 base(merge-base): 96802ca 文件: 5 个 +100/-0
关联 issue: #3605(open,核于 2026-11-16 — 追踪目录 issue,合并不关单)

机制核查:5 个重定基点(run_source_groups、comsub function_calls、trap_exec eval/DEBUG 两处、run_source_impl line_offset)把 end_position 与 position 同空间位移 — finish_compound_command 的 max(position, end_position) 取到折叠 { ... } 的 } 行,对应 GNU execute_intern_function 的 parse-end line_number 报 invalid identifier。机制贴合,无关改动/桥接层:无。

腿:

  • 钉自跑:issue3605_grouped_def_end_line 3/3 绿
  • fail-first:base 上 1 passed / 2 failed,红名 = {grouped_driver_def_reports_close_line, grouped_driver_late_def_reports_close_line}(fast-path 形 base 已正确)
  • lib 双边:head {issue2084_session_end_restores_host_process_state} / base 同 / 差集 {}
  • -D warnings:lib+bins 0;钉 stem 编译 0
  • 卫生:全部文件 rustfmt --check 0 diff
  • CI:红 = 3 job 仅 issue2875 基线;census skipped
  • GNU 对照(WSL GNU bash 5.3.20 脚本文件):三形态 GNU/head line 5/line 5/line 15 逐字节一致

F 点:无

合入阻断:本 PR 已 gh pr ready;#3678/#3680/#3681 合入后与其共享 script_driver.rs / source/execution.rs / trap_exec.rs / function_calls.rs 行区,GitHub 报 CONFLICTING/DIRTY(gh pr merge --squash 拒绝)。按车道规则跳过不合,需队长 rebase 或指定续作冲突解。

未跑/VOID 的腿:无

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3676 第2轮 — 处置:SKIP(DIRTY/CONFLICTING,按调度铁律不合入)
head: 091a437 base(merge-base): 96802ca 文件: 5 个 +100/-0
关联 issue: #3605(open,umbrella 目录 issue — 不关单;核于 2026-11-16 21:2x 本地)

处置理由(未重审内容,沿用本 PR 上一轮的 PASS 报告):

未跑/VOID 的腿:本轮未重跑内容腿(处置为冲突跳过);上一轮 PASS 报告的计数仅对旧 head 有效,rebase 后必须重跑钉自跑 + fail-first + lib 双边。

# Conflicts:
#	src/executor/function_calls.rs
#	src/executor/trap_exec.rs
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3676 第3轮 — CONFLICTING 已解,建议:PASS(合入待 CI 余量跑完)
head: 4fe3499(= 091a437 + merge origin/master c3bf91e)base: master(merge 后 diff 仍 +100/-0,5 文件)
关联 issue: #3605(open,umbrella — 合并不关单;核于 2026-11-16 本地)

冲突解法(机械,保持双方机制):

腿(逐项,对 merge 后 head 4fe3499 实测):

  • 钉自跑:issue3605_grouped_def_end_line 3 passed / 0 failed。
  • fail-first:master c3bf91e(独立 worktree 构建)同钉文件 → 1 passed / 2 failed,红名 = {issue3605_grouped_driver_def_reports_close_line, issue3605_grouped_driver_late_def_reports_close_line}(实得 line 4/line 13,期望 line 5/line 15),与 s6 轮声称完全一致;fast-path 形在 master 已正确。
  • lib 双边(顺序重跑,排除并行 %TEMP% 互踩——首次并行跑出现的 pathmatrix/issue863/窗口 listing 失败已证实为并行假红):head 1356 passed / 1 failed / 4 ignored / base master 1356 passed / 1 failed / 4 ignored / 失败名集双侧同 = {api::consumer_tests::issue2084_session_end_restores_host_process_state}(Windows 已知 flake)→ 差集 ∅。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --locked --lib --bins(merge 后树)→ 0 警告。
  • 卫生:rustfmt --edition 2021 --check 5 个 PR 文件 clean;marker-lint OK (117/268);utf8-boundary clean。
  • CI(head 4fe3499,run 43876891650/43876892025):已绿 = Rust tests、Rust tests 其余编译面、Compatibility CLI、Shell functionality、Cross-target darwin+linux/android、Windows compile check、API ledger tripwire、niubash builds;pending = GNU regression goldens、Regression pin stem census、Rust tests (macOS)。无 PR 专属红(issue2875 签名未出现)。
  • GNU 对照:WSL /usr/local/bin/bash 5.3.20(1)-release,脚本 target/t4-probes/p3676{a,b,c}.sh(fast-path / . -comment grouped / func5.sub 三 def 序列)→ rubash 与 GNU 逐行一致:line 6/line 6/line 16 invalid identifier(探针带 shebang 故 +1 行,钉内无 shebang 期望 line 5/15,语义同)。

续作记录:

  • 4fe349988 Merge remote-tracking branch 'origin/master' into pr3676 — 3 处冲突按上述口径解决(新 head 已 gh pr view 复核远端一致,mergeable=MERGEABLE)。

未跑/VOID 的腿:无(CI 3 项 pending 属在途,非 VOID)。

@caomengxuan666
caomengxuan666 merged commit f518475 into master Nov 16, 2026
10 of 12 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3676 第3轮 — 追加:已合入

CI 跑完(head 4fe3499):红 = GNU regression goldens and canaries(issue_753::case_9_declare_indexed_operand_binds_nothing + upstream_suite_slice_snapshots,与 master 基线逐名一致)+ Regression pin stem census(89 个失败,为 master 基线失败集的子集,无 PR 专属项)。其余全绿(Rust tests Linux+macOS、Compatibility CLI、Shell functionality、Cross-target ×2、Windows compile、API ledger、niubash builds)。

按 T 波 CONFLICTING 口径合入:squash f518475a2ecdce6b1678b51ce9c8c06419b6c699 @ 2026-11-16T13:50:31Z。#3605 为伞目录 issue,保持 OPEN。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant