Skip to content

fix: allow match expressions as cast and clone operands - #309

Open
akashchamp wants to merge 2 commits into
tree-sitter:masterfrom
akashchamp:fix-match-cast-clone-operand
Open

akashchamp wants to merge 2 commits into
tree-sitter:masterfrom
akashchamp:fix-match-cast-clone-operand

Conversation

@akashchamp

@akashchamp akashchamp commented Oct 22, 2026 •

Copy link
Copy Markdown

(int)match($x) { ... } and clone match($x) { ... } are valid PHP but parsed as errors, because cast_expression and clone_expression did not accept a match_expression operand. This adds it to both.

Fixes #308. I left (int)yield (also listed there) out, since it is a separate construct.

Checked with tree-sitter test (149/149 parses pass) and npm run lint. The new corpus test fails on the old parser and passes on the new one. Parser files are rebuilt by tree-sitter 0.27.1 in a separate chore: generate commit.

(int)match($x) { ... } and clone match($x) { ... } are valid PHP 8
but were parsed as errors, because cast_expression and clone_expression
only accepted unary/primary expressions.

Fixes tree-sitter#308

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.

Cast and clone operands reject match expressions: (int)match($x) {...} and clone match($x) {...} are parse errors

1 participant