From d8c59ba127937ae8d23a138153e4ca2d6dae4a24 Mon Sep 17 00:00:00 2001 From: Seiei Miyagi Date: Fri, 24 Jan 2020 20:12:37 +0900 Subject: [PATCH] [Fix #7647] Fix an `undefined method on_numblock` error when using Ruby 2.7's numbered parameters --- CHANGELOG.md | 2 ++ lib/rubocop/ast/traversal.rb | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d70c256cce6..ef2acb73f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * [#7639](https://github.com/rubocop-hq/rubocop/pull/7639): Fix logical operator edge case in `omit_parentheses` style of `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][]) * [#7661](https://github.com/rubocop-hq/rubocop/pull/7661): Fix to return correct info from multi-line regexp. ([@Tietew][]) * [#7655](https://github.com/rubocop-hq/rubocop/issues/7655): Fix an error when processing a regexp with a line break at the start of capture parenthesis. ([@koic][]) +* [#7647](https://github.com/rubocop-hq/rubocop/issues/7647): Fix an `undefined method on_numblock` error when using Ruby 2.7's numbered parameters. ([@hanachin][]) ### Changes @@ -4335,3 +4336,4 @@ [@pawptart]: https://github.com/pawptart [@gfyoung]: https://github.com/gfyoung [@Tietew]: https://github.com/Tietew +[@hanachin]: https://github.com/hanachin diff --git a/lib/rubocop/ast/traversal.rb b/lib/rubocop/ast/traversal.rb index 95e2ded8445..e08dfb68ab0 100644 --- a/lib/rubocop/ast/traversal.rb +++ b/lib/rubocop/ast/traversal.rb @@ -185,6 +185,15 @@ def on_case(node) alias on_when on_case alias on_irange on_case alias on_erange on_case + + def on_numblock(node) + children = node.children + child = children[0] + send(:"on_#{child.type}", child) + return unless (child = children[2]) + + send(:"on_#{child.type}", child) + end end end end