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

Fix NodePattern raising errors on some inputs #6834

Merged
merged 3 commits into from Mar 15, 2019

Conversation

marcandre
Copy link
Contributor

This fixes #5470

Note: the first two commits are not directly related, but make things a bit easier to debug.

@marcandre marcandre changed the title Nil node pattern Fix NodePattern raising errors on some inputs Mar 14, 2019
Copy link
Collaborator

@Drenmi Drenmi left a comment

Choose a reason for hiding this comment

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

Thanks @marcandre! 🙇

@Drenmi Drenmi merged commit ca1c08f into rubocop:master Mar 15, 2019
@Drenmi
Copy link
Collaborator

Drenmi commented Mar 15, 2019

If you're hungry for more, there's a long standing request to add an "any child" matcher. This would be especially helpful when matching on hashes. Consider:

ruby-parse -e '{ foo: 1, bar: 2 }'

(hash
  (pair
    (sym :foo)
    (int 1))
  (pair
    (sym :bar)
    (int 2)))

We may be interested in hashes that have a foo: 1 pair, but the pairs can appear in any order, so we can't reliably match that in a pattern. 🙂

What is needed is a suggested extension to the syntax, and the actual implementation.

@marcandre
Copy link
Contributor Author

@Drenmi Is there an issue already open for this? Doesn't seem very hard to do...

@Drenmi
Copy link
Collaborator

Drenmi commented Mar 16, 2019

@marcandre I don't think there's an issue, but feel free to open one. 🙂

@marcandre
Copy link
Contributor Author

@marcandre I don't think there's an issue, but feel free to open one. 🙂

Created #6841

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.

NodePattern fails extracting node types when presented with nil
2 participants