Skip to content

fix: bind conditional member access before logical operators - #445

Open
exKAZUu wants to merge 1 commit into
tree-sitter:masterfrom
exKAZUu:fix/conditional-access-precedence
Open

exKAZUu wants to merge 1 commit into
tree-sitter:masterfrom
exKAZUu:fix/conditional-access-precedence

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 15, 2026

Copy link
Copy Markdown

Close #233

var result = x || x?.C; now groups as x || (x?.C). A stateless external question token distinguishes definite member access from a ternary question, allowing member access to shift at its own precedence. It is emitted only after confirming a following dot that does not begin a decimal literal. Whitespace and comments remain separate extras.

The token is aliased to the existing ?, preserving public punctuation, fields, node names, and expression supertypes. The ordinary question alternative remains available; element-access/ternary disambiguation is unchanged. No serialized scanner state is added.

The corpus covers logical-or binding, explicit parentheses, intervening comments, and ?.5 as a ternary consequence. With upstream CLI 0.26.5, all 180 corpus tests and 892 highlight assertions pass; the new test fails on master. npm run lint passes, repeated generation is identical, and node-types.json is unchanged. Supplemental checks cover 212 parser inputs, 33 lexical boundaries, and 576 incremental/fresh parse comparisons, including all nine supertype queries.

Across 10,037 files from the four CI example projects, there are no new parse-error files. The 9,958 unchanged CSTs retain identical supertype captures. The remaining tree differences include member-access regrouping, 62 incidental nameof(...) pattern corrections, and one recovery change in an already erroneous preprocessor region. The C# SDK confirms all 62 nameof occurrences are constant patterns or constant-value case labels, not declarations, in their complete original files.

Recognize a definite member question separately from ternary questions so
member access can shift at its own precedence. Preserve ordinary question
handling and the existing public nodes and expression supertypes.

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.

Precedence incorrect between or and conditional access

1 participant