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
When targeting Ruby 2.2 and up, HashSyntax' autocorrect can produce invalid results. This happens for symbols like :'&&', for which Ruby 2.2 added support with the new hash syntax.
Expected behavior
With TargetRubyVersion: 2.2 in .rubocop.yml, when running rubocop -a, the following code:
{:'&&'=>:foo}
should be corrected to:
{'&&': :foo}
Actual behavior
The code is changed to:
{ &&: :foo}
This is syntactically invalid.
Steps to reproduce the problem
Create a file .rubocop.yml with:
AllCops:
TargetRubyVersion: 2.2
Create a file foo.rb with:
{ :'&&' => :foo }
Run rubocop -a.
RuboCop version
This bug occurs with:
0.52.0 (using Parser 2.4.0.2, running on ruby 2.2.6 x86_64-linux)
0.52.0 (using Parser 2.4.0.2, running on ruby 2.3.6 x86_64-linux)
0.52.0 (using Parser 2.4.0.2, running on ruby 2.4.3 x86_64-linux)
0.52.0 (using Parser 2.4.0.2, running on ruby 2.5.0 x86_64-linux)
This bug does not occur with:
0.50.0 (using Parser 2.4.0.0, running on ruby 2.2.6 x86_64-linux)
0.51.0 (using Parser 2.4.0.2, running on ruby 2.4.3 x86_64-linux)
The text was updated successfully, but these errors were encountered:
When targeting Ruby 2.2 and up, HashSyntax' autocorrect can produce invalid results. This happens for symbols like
:'&&'
, for which Ruby 2.2 added support with the new hash syntax.Expected behavior
With
TargetRubyVersion: 2.2
in.rubocop.yml
, when runningrubocop -a
, the following code:should be corrected to:
Actual behavior
The code is changed to:
This is syntactically invalid.
Steps to reproduce the problem
Create a file
.rubocop.yml
with:Create a file
foo.rb
with:Run
rubocop -a
.RuboCop version
This bug occurs with:
This bug does not occur with:
The text was updated successfully, but these errors were encountered: