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

Steep fails to pick up ivar type declaration in if statement #1390

Open
aaronmallen opened this issue Dec 6, 2024 · 1 comment
Open

Steep fails to pick up ivar type declaration in if statement #1390

aaronmallen opened this issue Dec 6, 2024 · 1 comment

Comments

@aaronmallen
Copy link

aaronmallen commented Dec 6, 2024

class Myclass
  # @rbs @foo: Hash[Symbol, untyped]?

  def initialize
    @foo = nil
  end

  # @rbs () -> void
  def main
    if @foo.nil?
      handle_nil_foo
    else
      # @type ivar @foo: Hash[Symbol, untyped]
      method_that_takes_hash(@foo)
    end
  end

  private

  # @rbs (Hash[Symbol, untyped] hash) -> void
  def method_that_takes_hash(hash)
    puts hash
  end
end

The above example will cause steep to raise ArgumentTypeMismatch error

@aaronmallen
Copy link
Author

After a bit of digging I'd like to offer some clarification on this. Steep will not allow @type declarations for ivars to override the defined type at all if the ivar is already has a defined signature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant