Skip to content

Conversation

@reese
Copy link
Collaborator

@reese reese commented Jan 6, 2026

Closes #762

This bit in the line metadata handling looks for "require" as a DirectPart to determine when we're in a series of require calls, which we insert a blank line after. This was happening after require: as a kwarg (or hash key etc.) in the Prism implementation because in Ripper, keys would always be a DirectPart of "name:", whereas Prism separately emitted the name and then a colon as two parts.

This PR tries to always emit assoc node keys as "name:" to circumvent this. I don't know if it's my favorite approach in the world (part of me wonders if we should instead have more descriptive token types that aren't just DirectPart for this), but this is what Ripper does, so I figured I'd keep it simple and just follow that.

Copy link
Collaborator

@froydnj froydnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if I'm a fan of this approach -- I think there's a lot of complexity around symbol nodes (e.g. 'require':) that I'm not sure this is going to handle. If nothing else, I think there should be some more tests around hashes with :require symbol keys in various formats (single-quoted, double-quoted, etc.). I know this same issue comes up with require: keys in hashes, so it'd be good to have tests for those regardless.

I do think having a proper MethodName token or some such that we can check for "require" instead of the current approach would be better and more robust overall. That would also handle the issue where we format require = foo with newlines after it, even though there isn't anything to require that.

@reese reese force-pushed the reese-require-kwarg branch from bb8c4a2 to 90d3713 Compare January 6, 2026 18:13
@reese reese requested a review from froydnj January 6, 2026 18:18
Copy link
Collaborator

@froydnj froydnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@reese reese merged commit b3fa128 into trunk Jan 6, 2026
8 checks passed
@reese reese deleted the reese-require-kwarg branch January 6, 2026 18:54
@froydnj
Copy link
Collaborator

froydnj commented Jan 6, 2026

This seems to have introduced a very few cases in ripper where a heredoc immediately followed by a receiver-less method call overindents the method call on Stripe's codebase. Trying to minimize a test case.

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.

[prism] require: kwarg causes blank lines to be inserted

3 participants