Skip to content

[existing] Typechecking false positives on anonymous argument forwarding #1108

@apiology

Description

@apiology

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions