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

+ ruby31.y: Allow value omission in Hash literals #818

Merged

Conversation

skryukov
Copy link
Contributor

Closes #817.

This commit tracks upstream commit ruby/ruby@c60dbcd

Copy link
Collaborator

@iliabylich iliabylich left a comment

Choose a reason for hiding this comment

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

Thanks! Initially I was thinking about a new node type (as always 🤦 ), but I like this approach a lot. Once the test is fixed I'd be glad to merge it.

s(:hash,
s(:pair, s(:sym, :a), s(:send, nil, :a)),
s(:pair, s(:sym, :b), s(:send, nil, :b))),
%q{{a:, b:}},
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a source_maps argument that has to be passed explicitly (%q{}).
Also, could you please add source maps checks for both key and value?

@skryukov skryukov force-pushed the allow_value_omission_in_hash_literals branch from 630de2b to f096464 Compare September 21, 2021 12:28
@skryukov skryukov force-pushed the allow_value_omission_in_hash_literals branch from f096464 to 56f12ab Compare September 21, 2021 12:34
Copy link
Collaborator

@iliabylich iliabylich left a comment

Choose a reason for hiding this comment

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

👍

@iliabylich iliabylich merged commit 22e6ca5 into whitequark:master Sep 21, 2021
@iliabylich
Copy link
Collaborator

@skryukov Thanks!

@skryukov skryukov deleted the allow_value_omission_in_hash_literals branch September 21, 2021 12:49
koic added a commit to koic/rubocop-ast that referenced this pull request Dec 12, 2021
Follow up to whitequark/parser#818

This PR adds `value_omission` method to `AST::PairNode` for Ruby 3.1's
hash value omission.
It can replace string match with that named API.
marcandre pushed a commit to rubocop/rubocop-ast that referenced this pull request Dec 12, 2021
Follow up to whitequark/parser#818

This PR adds `value_omission` method to `AST::PairNode` for Ruby 3.1's
hash value omission.
It can replace string match with that named API.
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.

ruby/ruby@c60dbcd
2 participants