Preserve keyword argument semantics through AST transformation#10
Merged
JPDuchesne merged 1 commit intomasterfrom Feb 25, 2026
Merged
Preserve keyword argument semantics through AST transformation#10JPDuchesne merged 1 commit intomasterfrom
JPDuchesne merged 1 commit intomasterfrom
Conversation
The upstream parser builder emits :hash nodes for both bare keyword arguments and explicit hash literals. Unparser uses node type to decide whether to emit braces, so kwargs were round-tripping as positional hashes — breaking Ruby 3.0+ strict keyword/positional separation. KwargsBuilder overrides associate to emit :kwargs nodes when no brace tokens are present, which Unparser already handles correctly. Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Parser::Builders::Default#associateemits:hashnodes for both bare keyword arguments (foo(bar: 1)) and explicit hash literals (foo({ bar: 1 })).Unparseruses the node type to decide whether to emit braces, so kwargs were round-tripping as positional hashes — breaking Ruby 3.0+ strict keyword/positional separation.KwargsBuilderwhich overridesassociateto emit:kwargsnodes when no brace tokens are present, whichUnparseralready handles correctly.KwargsBuilderand regression tests inTransformationTestfor keyword argument preservation throughtransform!.Test plan
KwargsBuilderunit tests (7 tests): bare kwargs, explicit hash, mixed positional+kwargs, standalone hash literals, pair preservation, constructor calls, double-splatTransformationTestregression tests (2 tests): kwargs and mixed kwargs survive atransform!round-tripMade with Cursor