Skip to content

Commit

Permalink
[Fix #6617] Prevent traversal error on infinite ranges
Browse files Browse the repository at this point in the history
With the addition of infinite ranges, the `irange` node type can
have one node type child and one `nil` type child. Our code made
the assumption that there would always be two node type children.
This change fixes that.
  • Loading branch information
Drenmi authored and bbatsov committed Jan 8, 2019
1 parent 698e622 commit 7cf76ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@
* [#6623](https://github.com/rubocop-hq/rubocop/pull/6623): Fix heredoc detection in trailing comma. ([@palkan][])
* [#6100](https://github.com/rubocop-hq/rubocop/issues/6100): Fix a false positive in `Naming/ConstantName` cop when rhs is a conditional expression. ([@tatsuyafw][])
* [#6526](https://github.com/rubocop-hq/rubocop/issues/6526): Fix a wrong line highlight in `Lint/ShadowedException` cop. ([@tatsuyafw][])
* [#6617](https://github.com/rubocop-hq/rubocop/issues/6617): Prevent traversal error on infinite ranges. ([@drenmi][])

## 0.62.0 (2019-01-01)

Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop/ast/traversal.rb
Expand Up @@ -23,7 +23,7 @@ def walk(node)
preexe postexe match_current_line defined?
arg_expr].freeze
MANY_CHILD_NODES = %i[dstr dsym xstr regexp array hash pair
irange erange mlhs masgn or_asgn and_asgn
mlhs masgn or_asgn and_asgn
undef alias args super yield or and
while_post until_post iflipflop eflipflop
match_with_lvasgn begin kwbegin return].freeze
Expand Down Expand Up @@ -176,6 +176,8 @@ def on_case(node)
alias on_ensure on_case
alias on_for on_case
alias on_when on_case
alias on_irange on_case
alias on_erange on_case
end
end
end

0 comments on commit 7cf76ff

Please sign in to comment.