Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle arbitrary expression types in aref_field nodes #381

Merged
merged 4 commits into from
Dec 3, 2022

Conversation

reese
Copy link
Collaborator

@reese reese commented Dec 3, 2022

Resolves #380

aref_field nodes (e.g. foo[:bar] = :baz) can really handle any expression in the index position, and in reality they can handle any number of items for users overriding #[]=, so we should handle an arbitrary expression list here.

Comment on lines +8 to +21
a[
class A
def foo
puts(a)
end
end
] = ""
a[
begin
""
rescue StandardException
""
end
] = ""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm gonna call this a "reasonable" rendering? I mean, users writing this is already pretty surprising, so I think this is the most consistent way to handle it rather than special-casing aref fields to inline these or something like that 🤷‍♂️

self.line_numbers.len() > 1 || self.any_collapsing_newline_has_heredoc_content()
self.line_numbers.len() > 1
|| self.any_collapsing_newline_has_heredoc_content()
|| self.contains_hard_newline()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also think this was a latent bug we've had around forever -- some expressions are essentially always multiline (e.g. classes), so breakables that have these in them should always render multiline.

@reese reese requested a review from fables-tales December 3, 2022 18:03
@reese reese merged commit d6ee1c7 into trunk Dec 3, 2022
@reese reese deleted the reese-aref-expression branch December 3, 2022 20:05
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.

Command calls in ArefFields fail to deserialize
2 participants