Repository navigation
test(parser): pin GNU semantics for tokens on the function-definition brace line (rubash#443) - #459
Merged
Merged
Conversation
… brace line (rubash#443) #443 reported that any trailing token on the `f() {` line — a `# comment`, or the first body word with the `}` closing on a later line — was rejected with "syntax error near unexpected token `('" on the b4cbcad build, against a mangled `f ( ) {` re-rendering. On current master every row of the issue's measured scope table already behaves like GNU bash 5.x: the underlying lexer faults (the brace-group token swallowing trailing comment text, and has_unclosed_brace_group not continuing the logical line across a function header) were fixed with the niubash #120 follow-up whose regressions live in tests/issue120_fndef_inline_comment.rs. This adds the missing black-box pins for the rest of the #443 scope: - bodies that open on the brace line and close on a later line, including body + trailing comment and assignment + comment shapes; - one-liner `f() { :; }` definitions with and without a trailing comment, and the comment not swallowing following lines; - `}` followed by a comment (legal) vs a bare word (rc=2 syntax error naming THAT word, with the physical offending line echoed verbatim — not the mangled `f ( ) {` rendering); - control rows the issue measured as already correct; - no interference with the rubash#453 assignment-prefix + subshell parse inside a body whose brace line carries a comment. Closes #443
This was referenced Oct 10, 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.
Closes #443
What #443 reported
Any trailing token on the
f() {line — a# comment, or the first bodyword with the
}closing on a later line — was rejected on the reportedbuild (rubash b4cbcad / niu 1.1.2) with
syntax error near unexpected token('against a mangledf ( ) {`re-rendering, rc=2, before any execution.
Findings on current master
Every row of the issue's measured scope table already matches GNU bash
5.x on this branch. The underlying lexer faults (the brace-group token
swallowing trailing comment text, and
has_unclosed_brace_groupnotcontinuing the logical line across a function header) were fixed with
the niubash #120 follow-up;
tests/issue120_fndef_inline_comment.rsalready pins the comment-after-brace shapes. No parser change is needed.
What this PR adds
Black-box regression pins (
tests/issue443_func_line_trailing_tokens.rs,CARGO_BIN_EXE_rubash) for the rest of the #443 scope that was not yetcovered:
f() { echo hi # candf() { x=1 # c(assignment + comment);f() { :; }with and without a trailing comment, and thecomment not swallowing following lines;
}followed by a# comment(legal) vs a bare word (rc=2, error namesTHAT word, physical offending line echoed verbatim — not
f ( ) {);on its own line, complete one-liner);
inside a body whose brace line carries a comment.
Verification
cargo fmt --checkclean.issue120_fndef_inline_comment(13),assign_prefix_subshell_regressions(fix(parser): 赋值前缀 + 子 shell — GNU 形态(审计语料 #452 集群1) #453, 3),issue314_nested_funcdef_loop_regressions(12), lib tests 623 passed.PR): one
pwdlib test and thecli_testsbashdb/examples rows thatrequire the absent
third_party/bashvendored tree.