Skip to content

fix(bash): preserve whitespace after empty assignments - #1107

Open
denisvmedia wants to merge 1 commit into
odvcencio:mainfrom
denisvmedia:fix/bash-empty-environment-values
Open

fix(bash): preserve whitespace after empty assignments#1107
denisvmedia wants to merge 1 commit into
odvcencio:mainfrom
denisvmedia:fix/bash-empty-environment-values

Conversation

@denisvmedia

Copy link
Copy Markdown

Fixes #1106.

! A=x B= command must leave B empty and preserve command as the command name. The opening-parenthesis probe consumed the separating whitespace before the scanner reached EMPTY_VALUE. Some inputs produced a missing word. Others produced an incorrect assignment without an error flag.

Preserve whitespace when EMPTY_VALUE is valid. The existing scanner then emits its zero-width token. The change adds one condition and leaves grammar data, token identities, and parser recovery unchanged.

Add shared inputs and blackbox tests:

  • Check assignment values, command names, byte ranges, and HasErrorOrMissing().
  • Cover negation, multiple assignments, tabs, CRLF, Unicode, substitutions, redirects, pipelines, case bodies, arrays, and quoted values.
  • Keep incomplete syntax invalid.
  • Compare valid inputs with the locked C grammar across strict, production, and raw Go parsing.
  • Include the new C comparison in the existing CI job.

Validation used a dedicated Linux Docker container with two CPUs and an 8 GiB memory limit. No repository-wide host sweep ran.

  • Before the fix: 12 of 18 new cases failed.

  • With the fix: all 18 cases and available Bash regressions passed.

  • The locked C comparison passed for 16 valid inputs across three routes. It checks symbols, fields, byte/point spans, flags, child order, and deep digests.

  • Existing Bash fresh/incremental parity and C-reference regressions passed.

  • The final fix passed Bash race tests on Go 1.27.0.

  • Bash tests passed with CGO_ENABLED=0 on Go 1.22.0, the module's declared minimum compiler.

  • Actionlint passed for the changed workflow.

TestBashForestRepetitionFoldDispatch skipped because its optional real-corpus fixture was absent.

Reproduce the scoped checks inside a Docker container:

go test -race ./grammars -run '^Test(Issue1106Bash|Bash)' -count=1
CGO_ENABLED=0 GOTOOLCHAIN=go1.22.0 go test ./grammars -run '^Test(Issue1106Bash|Bash)' -count=1
cd cgo_harness
go test . -tags treesitter_c_parity -run '^(TestBash.*COracleParity|TestIssue1106BashEmptyAssignmentsCParity)$' -count=1
GTS_PARITY_MODE=smoke go test . -tags treesitter_c_parity -run '^TestParity(FreshParse|IncrementalParse|HasNoErrors)$/^bash$' -count=1

Copilot AI lite review requested due to automatic review settings September 9, 2026 15:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

[parser]: Bash: spurious missing word in negated commands with an empty environment assignment

2 participants