rubocop / rubocop-performance

An extension of RuboCop focused on code performance checks.
https://docs.rubocop.org/rubocop-performance
MIT License
670 stars 79 forks source link

Performance/RedundantBlockCall produces invalid code #448

Closed TastyPi closed 5 months ago

TastyPi commented 5 months ago
class RubocopIssue
  def self.around(&around_block)
    define_method(:around) do |&test_block|
      around_block.call { super(&test_block) }
    end
  end
end

gets turned into

class RubocopIssue
  def self.around(&around_block)
    define_method(:around) do |&test_block|
      yield { super(&test_block) }
    end
  end
end

which is a syntax error:

syntax error, unexpected '{' (SyntaxError)
      yield { super(&test_block) }
            ^

Expected behavior

rubocop-performance should only produce valid code

Actual behavior

rubocop-performance produced a syntax error

Steps to reproduce the problem

Run rubocop-performance on the example above

RuboCop version

1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.2.2) +server [x86_64-linux]