solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

[existing] Typechecking false positives on anonymous argument forwarding

Open apiology opened this issue 3 months ago • 1 comments

Ruby has some anonymous argument forwarding that we should at least not complain about in typechecking:

#!/usr/bin/env ruby

class Foo
  # @param arg [String]
  # @param kwarg [String]
  def initialize(arg, kwarg:)
    @arg = arg
    STDERR.puts("Got arg: #{arg}")
    @kwarg = kwarg
    STDERR.puts("Got kwarg: #{kwarg}")
  end
end

class FooProxy1 < Foo
  def initialize(*, **)
    super
    puts "Created!"
  end
end

class FooProxy2 < Foo
  def initialize(...)
    super(...)
    puts "Created!"
  end
end

FooProxy1.new("my arg", kwarg: "my kwarg")

FooProxy2.new("my arg", kwarg: "my kwarg")

False positive complaints (strong level):

repro.rb:22 - Missing @param tag for  on FooProxy2#initialize
repro.rb:23 - Not enough arguments to Foo#initialize
repro.rb:30 - Too many arguments to FooProxy2.new

apiology avatar Oct 03 '25 13:10 apiology