Arjes
Arjes

Reputation: 79

Sorbet not picking up obvious mismatch of Hash signature

Given the following code:

# typed: strict

extend T::Sig

sig { params(x: T::Hash[String,String]).returns(NilClass) }
def foo(x); end

foo("foo" => 123)

Playground Link

I would expect Sorbet to recognize that the passed hash has the wrong value parameter. How can I properly declare a signature which will ensure the hash passed only contains allowed values types?

Upvotes: 2

Views: 344

Answers (1)

jez
jez

Reputation: 1287

Unfortunately, this is a known issue in Sorbet

https://github.com/sorbet/sorbet/issues/713

You're doing everything right, and Sorbet let you down. Feel free to follow the issue, but we estimate that this particular bug will be quite hard to fix, because of some other constraints we're trying to maintain.

Upvotes: 2

Related Questions