Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override a function with a block fails #1497

Open
HoneyryderChuck opened this issue Sep 4, 2023 · 0 comments
Open

override a function with a block fails #1497

HoneyryderChuck opened this issue Sep 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@HoneyryderChuck
Copy link
Contributor

HoneyryderChuck commented Sep 4, 2023

  • 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.

@soutaro soutaro added the bug Something isn't working label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants