You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Lint/OutOfRangeRegexpRef does not seem to recognize regular expressions (which have capture groups) that are used in Ruby's new pattern matching syntax. The cop fails to recognize captures when the regex is used in a case-in expression as well as the => array syntax.
Both forms invoke Regexp#=== under the hood, which still trigger's ruby's Regexp.last_match capabilities (as well as setting the 'last-match' special global variables like $1). Since the variables are set from the captured groups, I would expect rubocop's linter to recognize them as valid capture references.
The Lint/OutOfRangeRegexpRef does not seem to recognize regular expressions (which have capture groups) that are used in Ruby's new pattern matching syntax. The cop fails to recognize captures when the regex is used in a
case-in
expression as well as the=>
array syntax.Both forms invoke
Regexp#===
under the hood, which still trigger's ruby'sRegexp.last_match
capabilities (as well as setting the 'last-match' special global variables like$1
). Since the variables are set from the captured groups, I would expect rubocop's linter to recognize them as valid capture references.Expected behavior
Ruby's new pattern matching syntax accepts regular expressions and captures groups. It still stores captures in the special globals as documented here: https://ruby-doc.org/core-3.1.2/Regexp.html#class-Regexp-label-Special+global+variables
Actual behavior
Rubocop doesn't recognize the regex pattern in the "case-in", nor "arrow" pattern matching syntax.
in both cases, it prints:
Steps to reproduce the problem
The two ruby snippets above will reproduce the cop error.
RuboCop version
The text was updated successfully, but these errors were encountered: