Skip to content

fix: preserve slice-only list patterns before logical operators - #444

Open
exKAZUu wants to merge 1 commit into
tree-sitter:masterfrom
exKAZUu:fix/slice-pattern-operator-precedence
Open

exKAZUu wants to merge 1 commit into
tree-sitter:masterfrom
exKAZUu:fix/slice-pattern-operator-precedence

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 15, 2026

Copy link
Copy Markdown

items is [..] && ready currently parses the list as a collection expression inside a constant pattern, so && ready becomes part of the pattern. The same problem affects ||.

Give a completed bare slice higher precedence than a range expression, while keeping slices with a following subpattern on their existing path. The regression corpus checks that the logical operator remains outside is and that [..] is a list_pattern containing a slice_pattern.

Verified with upstream tree-sitter CLI 0.26.5: all 180 corpus tests and 892 highlight assertions pass; the new test fails against the original parser. npm run lint also passes. Existing collection/range/list controls retain identical CSTs and expression, lvalue, non-lvalue, and pattern query captures. The generated node schema is unchanged.

Complete a bare slice before it can reduce to a collection range element.
Keep slices with a following subpattern on their existing precedence path.

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>

This branch has not been deployed

No deployments
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.

1 participant