Skip to content

Comment after a heredoc-word: echo x <<EOF>#comment treats the # tail as heredoc/word text (GNU: syntax error near newline) #305

Closed

Description

@caomengxuan666

Found by wt11/lexmix during #304 (no comsub needed to reproduce). After the heredoc word, GNU's tokenizer reports a syntax error near the newline; we swallow the # tail as heredoc-trailer/word text. Adjacent to the just-landed <<< operator consumption — likely the same heredoc-word collection not enforcing the token boundary. GNU anchor: parse.y:3630-3643 token-boundary rules + the heredoc word grammar (only the next NEWLINE may follow the delimiter word).

Activity

  1. added
    bug
    on Sep 28, 2026
  2. added a commit that references this issue on Sep 29, 2026
  3. caomengxuan666 commented on Sep 29, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt12/heredocfix (71866dcd, master 6e8aebe): is_redirect_target_token still admitted TokenKind::HereDocBody as a redirect operand (a leftover from 6747ed3), so the > after <<EOF opened the heredoc first BODY line as a filename. Class-level fix in three places: the admission removed (covers all redirect operator positions at once); missing_redirect_target_node gained the HereDocBody-to-newline branch with the physical close line carried on the token (per GNU parse.y:5305/5688 word ends at meta chars, :3648-3654 newline to yacc only after gather_here_documents:3651, line numbering make_cmd.c:512/580, error shape parse.y:6833/6814); compound-command tails route dangling redirect operators to the same diagnostic.

    Verification: 41-case matrix byte-identical to WSL GNU Bash 5.3.0; 14 new regressions; heredoc suite 0 diff both sides; cli_tests A/B vs base identical 19 pre-existing failures, zero new. Leftovers filed separately: in-comsub heredoc delimiter swallow (lexmix family) and eval rc=2 continuation.

  4. added a commit that references this issue on Sep 29, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions