Skip to content

[bug] Spurious syntax error: { case...esac; cmd # comment } — brace group fails to close after case + trailing comment (kills modernish launcher parse) #219

Closed

Description

@caomengxuan666

Found via modernish test suite (ecosuite lane). rubash -n rejects bin/modernish wholesale (rc=2), while GNU bash 5.3.0 accepts it. Reduced to a 7-line minimal form.

Minimal reproducer (WSL GNU Bash 5.3.0 = oracle)

p37.sh:

{
	case x in
	( s )	one
	;;
	esac
	echo hi	# comment
}
  • GNU bash 5.3.0 bash -n p37.sh: rc=0
  • rubash rubash.exe -n p37.sh: rc=2, line 2: syntax error: unexpected end of file from '{' command on line 1

Ingredients (reduction matrix saved under target/issue-suites/results/ecosuite/modernish/probes/)

  • { ... } brace GROUP required: same body in a function f() { ... } parses fine (p44), no wrapper parses fine (p38).
  • a case...esac earlier in the group is required (p43 { echo hi # comment } alone is fine; p42 if..fi variant is fine).
  • the comment must be the last content before the closing } (p40, which adds one more command after the comment, is fine).
  • leading-paren case arms, &, fd-redirects, while/let not required (p34 still fails with none of them).

In the wild this appears as: modernish bin/modernish script-side die() body — { { ...trap loops... put ... >| /dev/tty ...; if ! is onterminal 2; then ...; fi } & } 8<&0 nested inside a case $- in ( * ) arm — reported by rubash as line 307: syntax error near unexpected token 'then' with the preceding lines folded into one; the whole 2700-line launcher then refuses to parse. Same file passes GNU bash -n.

GNU C source owner

  • parse.y:1196 group_command: '{' compound_list '}' — the lexer skips comments as whitespace; a #... line inside a compound list cannot extend or close the group. rubash's brace-scan/termination logic (cf. HEAD 9bf2df9 "resumable brace-scan cache") must not let a trailing comment before } poison the close detection after a case statement.

Artifacts

  • target/issue-suites/results/ecosuite/modernish/probes/ p11a..p45 reduction chain, bis*.sh variants, p37.sh minimal
  • modernish @ 63bdae02eeda8ae2ffb9b517cf26a6f4fd52e180

Lane: wt4/ecosuite evaluation suites (no src/ fixes in lane).

Activity

  1. added a commit that references this issue on Sep 27, 2026
  2. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(commit d3e8aff,lane wt4/ecofix,GNU 引用见提交;探针/夹具与 WSL GNU 5.3.0 字节一致)。感谢报告!

  3. added
    bug
    area:parser
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:parserbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions