-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support endless range from Ruby 2.6 #7159
Labels
Comments
8 tasks
Thanks for the feedback. I opened a PR #7160. |
koic
added a commit
to koic/rubocop
that referenced
this issue
Jun 21, 2019
Fixes rubocop#7159. This PR fixes the following error for `Lint/DuplicatedKey` when using endless range in Ruby 2.6. ```console % rubocop -V 0.71.0 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-darwin17) % cat example.rb { 42.. => false } % rubocop --only Lint/DuplicatedKey -d For /private/tmp/7159: configuration from /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/config/default.yml Inspecting 1 file Scanning /private/tmp/7159/example.rb An error occurred while Lint/DuplicatedKey cop was inspecting /private/tmp/7159/example.rb:1:0. undefined method `recursive_basic_literal?' for nil:NilClass /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/ast/node.rb:408:in `all?' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/ast/node.rb:408:in `block (2 levels) in <class:Node>' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/lint/duplicated_key.rb:27:in `select' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/lint/duplicated_key.rb:27:in `on_hash' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/commissioner.rb:59:in `block (2 levels) in trigger_re sponding_cops' (snip) ``` There are the following differences in the AST generated by Parser gem. ```console % ruby-parse -e '(42..nil)' (begin (irange (int 42) (nil))) % ruby-parse -e '(42..)' (begin (irange (int 42) nil)) ``` This PR works with `nil` representing the endless range.
bbatsov
pushed a commit
that referenced
this issue
Jun 21, 2019
Fixes #7159. This PR fixes the following error for `Lint/DuplicatedKey` when using endless range in Ruby 2.6. ```console % rubocop -V 0.71.0 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-darwin17) % cat example.rb { 42.. => false } % rubocop --only Lint/DuplicatedKey -d For /private/tmp/7159: configuration from /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/config/default.yml Inspecting 1 file Scanning /private/tmp/7159/example.rb An error occurred while Lint/DuplicatedKey cop was inspecting /private/tmp/7159/example.rb:1:0. undefined method `recursive_basic_literal?' for nil:NilClass /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/ast/node.rb:408:in `all?' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/ast/node.rb:408:in `block (2 levels) in <class:Node>' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/lint/duplicated_key.rb:27:in `select' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/lint/duplicated_key.rb:27:in `on_hash' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/commissioner.rb:59:in `block (2 levels) in trigger_re sponding_cops' (snip) ``` There are the following differences in the AST generated by Parser gem. ```console % ruby-parse -e '(42..nil)' (begin (irange (int 42) (nil))) % ruby-parse -e '(42..)' (begin (irange (int 42) nil)) ``` This PR works with `nil` representing the endless range.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Latest version doesn't have support of added feature
endless ranges
in Ruby 2.6.Expected behavior
In case of proper syntax for endless range, Rubocop should pass
Actual behavior
It fails with error
Steps to reproduce the problem
I created repo with 2 test files (ruby files and rubocop config).
https://github.com/antonzaytsev/rubocop-endless-range-issue.
Literally any code with endless range will break rubocop.
For example
RuboCop version
The text was updated successfully, but these errors were encountered: