Repository navigation
fix!: correct postfix cast and unary precedence - #38
Merged
Merged
Conversation
Keep postfix updates inside surrounding casts and unary expressions. Reuse a postfix-only rule in intersection casts so valid operands retain their public update node and query structure. BREAKING CHANGE: update_expression children are primary_expression rather than expression, and postfix update nesting follows the Java operand. Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
(Object) value++parses as an update of a cast, and-value++parses as an update of a unary result. This silently misrepresents valid Java expression nesting. The compiler-checked fixture exposes eleven incorrect structures among twenty methods.This follows the precedence fix in
grammar-orchard/tree-sitter-java-orchardcommit03fc6cd3. Its exact patch corrects the ordinary cases but introduces errors for valid intersection postfix casts; a shared postfix-only rule covers those too.Requirements
required: Improve the forked grammar repositories, excluding CSS and Markdown, as much as possible; backward compatibility may be ignored.
required: Review fork issues and major upstream issues, PRs and recent commits; check target PRs for duplicates and use a dedicated PR from latest main for each eligible origin.
required: Run review-booster and complete-pr concurrently, then release the changes, and continue the remaining eligible items.
required: Expose the actual nesting of valid Java expressions to structural parser queries.
chosen: Resolve the postfix/cast precedence origin from grammar-orchard/tree-sitter-java-orchard commit
03fc6cd3separately from the intersection-operand origin already released in 8.0.3.chosen: Restrict update operands to primary expressions and retain existing public node names; this prevents casts and unary results from becoming update targets while preserving variable, field, array and parenthesized targets.
chosen: Share a postfix-only hidden rule aliased to update_expression inside intersection casts; the exact upstream patch introduced errors for two compiler-valid intersection updates, and admitting prefix updates there would violate the Java cast syntax.
chosen: Publish a major release because update_expression.children narrows from expression to primary_expression and corrected nesting changes structural query expectations; no compatibility shim is needed.
Customer Summary
Postfix increments and decrements stay inside surrounding casts and unary expressions. This is a major release: update operands are primary expressions, and queries expecting cast or unary nodes directly under an update must follow the corrected nesting.
Technical Summary
Use right associativity for casts and updates and restrict update operands to primary expressions. Share postfix parsing through a hidden rule aliased to the existing
update_expressionin intersection-cast values, preserving its public name while excluding prefix updates there. Regenerate the parser and schema. The only schema change isupdate_expression.children:expressionbecomesprimary_expression.The corpus covers twenty complete methods with primitive/reference/intersection casts, prefix/postfix operators, nested casts, unary operators, parentheses, fields and arrays. The API regression checks query captures through the alias and ordinary updates. README examples use grammar major 9 with the same tested runtime 9.
Testing
bun run verifypassed with no code-gauge findings; 69 focused tests in 13 files and Rust unit/doc tests passed.-x++reparenting, with identical token metadata and all 17 methods' shipped captures unchanged.Notes
The scope is expression structure. Variable assignability and type checking remain the Java compiler's responsibility. Scoped control comparisons do not claim universal parser parity.