fix(parser): treat do/done as words inside for/select in-list#2123
Merged
Conversation
Reserved words (do, done, in, ...) are only keywords in command position. Inside a `for`/`select` `in` list they are ordinary words until a list terminator (`;` or newline). The parser broke the word-list loop on the first `do`, so `for a in do; do echo $a; done` parsed an empty list and produced no output instead of `do`. Found by the nightly differential proptest (multi_statement_matches_bash). Adds for_in_reserved_word_tests.rs covering the reproducer and bash parity.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | f916f88 | Commit Preview URL Branch Preview URL |
Jun 24 2026, 09:16 AM |
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.
Problem
The nightly differential proptest (
multi_statement_matches_bash) went red on 2026-06-24 (run 28076841758) with the minimal failing input:Root cause
Reserved words (
do,done,in, …) are keywords only in command position. Inside afor/selectinlist they are ordinary words until a list terminator (;or newline). The word-list parser broke the loop on the firstWord("do"), so the list parsed as empty and the loop produced no output.Fix
Remove the special-case
dobreak in both theforandselectword-list loops (crates/bashkit/src/parser/mod.rs). The list now ends only at;/newline/non-word, matching bash. This also makesfor a in done; …, multi reserved-word lists, etc. parse correctly.Tests
Added
for_in_reserved_word_tests.rscovering the reproducer plus bash-parity cases. Verified output matches real bash exactly:for a in do; do echo $a; donedofor a in do done then in; do echo $a; donedo/done/then/infor a in done\ndo echo $a; donedonefor a in 1 2 3; do echo $a; done1/2/3Note: full
cargo testcould not run in the authoring sandbox (egress policy blocks thejitergit dep pinned via[patch.crates-io]); the change was verified through a standalone harness against the realbashkitcrate and against real bash. CI provides the authoritative check.Generated by Claude Code