rbs icon indicating copy to clipboard operation
rbs copied to clipboard

Duplicate type definitions for `rbs prototype rb` in certain cases.

Open tmimura39 opened this issue 2 years ago • 0 comments

Similar to https://github.com/ruby/rbs/issues/1345.

# callable.rb
module Callable
  extend ActiveSupport::Concern

  # https://api.rubyonrails.org/v7.0.5/classes/ActiveSupport/Concern.html#method-i-class_methods
  class_methods do
    def call(...)
      new(...).call
    end
  end

  def call(*)
    raise NotImplementedError
  end
end
$ rbs prototype rb -osig callable.rb --force
Processing `callable.rb`...
  Generating RBS for `callable.rb`...
    - Writing RBS to existing file `sig/callable.rbs`...
# cat sig/callable.rbs
module Callable
  extend ActiveSupport::Concern

  def call: (*untyped) ?{ () -> untyped } -> untyped

  def call: (*untyped) -> untyped
end
$ rbs -Isig validate --silent
/gems/rbs-3.1.0/lib/rbs/definition_builder/method_builder.rb:38:in `block in validate!': sig/callable.rbs:4:2...4:52: ::Callable#call has duplicated definitions in sig/callable.rbs:6:2...6:33 (RBS::DuplicatedMethodDefinitionError)

    def call: (*untyped) ?{ () -> untyped } -> untyped
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Duplicate call method types are defined. I think method definitions in blocks such as ActiveSupport::Concern.class_methods should be ignored.

tmimura39 avatar May 31 '23 04:05 tmimura39