Skip to content

override a function with a block fails #1497

@HoneyryderChuck

Description

@HoneyryderChuck
  • rbs: 3.1.3
  • ruby: 3.2.2

i'm finding an issue typing the following structure:

class A
  def initialize(a, b)
    @a = a
    @b = b
  end
end

class B < A

  def initialize(a, b)
    super

    yield self if block_given?
end
class A
  def initialize: (Integer a, String b) -> void
end

class B
  def initialize: (Integer a, String b) { (self) -> void } -> void
end

When I use runtime type-checking via rbs test using smth like B.new(1, "a") { |b| puts b }, I get an error similar to:

RuntimeError: Neutered Exception RBS::Test::Tester::TypeError: TypeError: [B#initialize] ArgumentTypeError: expected `String` (b) but given `1`

Where the first argument is being incorrectly passed the second argumet type def.

I can workaround that now by doing the block-based definition on A's rbs file, which is wrong, but it at least fixes it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions