Steep 2.0.0 incorrectly reports a type error when passing an interned value to Hash#key?, even though interned should be compatible with my type signature. This worked correctly in Steep 1.10.0.
Environment
- Steep version: 2.0.0
- RBS version: 4.0.2
- Ruby version: 3.2.4, 4.0.2
Ruby:
class Example
def initialize
@shas = {}
end
def script_sha(script_name)
if shas.key?(script_name) # Type error here
shas[script_name]
end
end
end
RBS:
class Example
attr_reader shas: Hash[interned, String]
def script_sha: (interned script_name) -> String?
end
Error Message
lib/example.rb:4:17: [error] Cannot pass a value of type `::interned` as an argument of type `::Hash::_Key`
│ ::interned <: ::Hash::_Key
│ (::Symbol | ::string) <: ::Hash::_Key
│ ::string <: ::Hash::_Key
│ (::String | ::_ToStr) <: ::Hash::_Key
│ ::_ToStr <: ::Hash::_Key
│
│ Diagnostic ID: Ruby::ArgumentTypeMismatch
│
└ if shas.key?(script_name)
~~~~~~~~~~~
This code type-checked successfully in Steep 1.10.0. interned is a built-in RBS type alias defined as Symbol | String
Steep 2.0.0 incorrectly reports a type error when passing an
internedvalue toHash#key?, even though interned should be compatible with my type signature. This worked correctly in Steep 1.10.0.Environment
Ruby:
RBS:
Error Message
This code type-checked successfully in Steep 1.10.0.
internedis a built-in RBS type alias defined asSymbol | String