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

on_const not being called for second arg of return #3223

Closed
ptarjan opened this issue Jun 15, 2016 · 5 comments
Closed

on_const not being called for second arg of return #3223

ptarjan opened this issue Jun 15, 2016 · 5 comments

Comments

@ptarjan
Copy link
Contributor

ptarjan commented Jun 15, 2016

Expected behavior

on_const is called for this program

$ cat a.rb
def foo
  return A, B
end
$ ruby-parse a.rb
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.8-compliant syntax, but you are running 2.1.2.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(def :foo
  (args)
  (return
    (const nil :A)
    (const nil :B)))

Actual behavior

on_const isn't called

Steps to reproduce the problem

Write a rubocop rule with a on_const and see it isn't called for B.

RuboCop version

Include the output of rubocop -V:

$ rubocop -V
0.40.0 (using Parser 2.3.1.0, running on ruby 2.1.2 x86_64-darwin15.0)
@jonas054
Copy link
Collaborator

Looks like this is a bug in traversal.rb where :return is listed as a node that can only have one child. Do you have time to fix this yourself, @ptarjan?

@ptarjan
Copy link
Contributor Author

ptarjan commented Jun 17, 2016

Sure, seems like a simple PR.

@ptarjan
Copy link
Contributor Author

ptarjan commented Jun 17, 2016

@jonas054 where are the tests for traversal.rb?

@jonas054
Copy link
Collaborator

Seems we don't have any. Except that Traversal is so central it's included in pretty much all the tests.

@ptarjan
Copy link
Contributor Author

ptarjan commented Jun 17, 2016

Ok. I just picked a random cop that was using on_const and wrote a test for it.

Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
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

No branches or pull requests

2 participants