Skip to content

Conversation

@knutwannheden
Copy link
Contributor

@knutwannheden knutwannheden commented Feb 10, 2026

When parsing case [c], _:, the outer implicit tuple MatchSequence was greedily consuming the [ that belongs to the inner child MatchSequence. This caused the pattern to be parsed as a single bracketed list [c, _] instead of an implicit tuple containing [c] and _.

The fix adds __is_own_sequence_delimiter which checks whether a [ or ( delimiter belongs to this MatchSequence or to its first child by combining AST inspection (is the first child also a MatchSequence?) with token peeking (are there consecutive delimiters?).

Also includes RPC server improvements: relativeTo path support for parse inputs, bare string PathInput handling, and better error logging.

When parsing `case [c], _:`, the outer implicit tuple MatchSequence
was greedily consuming the `[` that belongs to the inner child
MatchSequence. This caused the pattern to be parsed as a single
bracketed list `[c, _]` instead of an implicit tuple containing
`[c]` and `_`.

The fix adds `__is_own_sequence_delimiter` which checks whether a `[`
or `(` delimiter belongs to this MatchSequence or to its first child
by combining AST inspection (is the first child also a MatchSequence?)
with token peeking (are there consecutive delimiters?).

Also includes RPC server improvements: relativeTo path support for
parse inputs, bare string PathInput handling, and better error logging.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Feb 10, 2026
@knutwannheden knutwannheden changed the title Fix MatchSequence parser incorrectly consuming child's delimiter Python: Fix MatchSequence parser incorrectly consuming child's delimiter Feb 10, 2026
@knutwannheden knutwannheden merged commit 4bab9b4 into main Feb 10, 2026
1 check passed
@knutwannheden knutwannheden deleted the fix-match-sequence-delimiter-parsing branch February 10, 2026 18:13
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants