You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I should not be seeing any errors, but steep is returning the following:
app/models/items.rb:14:29: [hint] Cannot detect the type of the expression
│ Diagnostic ID: Ruby::FallbackAny
│
└ def initialize(attrs = {})
~~
app/models/items.rb:14:21: [hint] Cannot assign a value of type `::Hash[untyped, untyped]` to an expression of type `::modelsItemsSwordAttrs`
│ ::Hash[untyped, untyped] <: ::modelsItemsSwordAttrs
│ ::Hash[untyped, untyped] <: ({ ?:sharpness => ::Integer } & ::modelsItemsBaseAttrs)
│ ::Hash[untyped, untyped] <: { ?:sharpness => ::Integer }
│
│ Diagnostic ID: Ruby::IncompatibleAssignment
│
└ def initialize(attrs = {})
~~~~~~~~~~
app/models/items.rb:16:21: [error] Cannot find compatible overloading of method `[]` of type `({ ?:sharpness => ::Integer } & { ?:durability => ::Integer })`
│ Method types:
│ def []: (:durability) -> (::Integer | nil)
│ | (:durability) -> ::Integer
│
│ Diagnostic ID: Ruby::UnresolvedOverloading
│
└ @sharpness = attrs[:sharpness] || 1
Weird things:
Steep complains about attrs being Ruby::FallbackAny when clearly it is a hash, both the default value and the typing
It doesn't like assigning a Hash on line 14, but has no problem doing the same thing on line 6??
If I move modelsItemsBaseAttrs to the front of the intersection for type modelsItemsSwordAttrs, i.e. type modelsItemsSwordAttrs = modelsItemsBaseAttrs & { ?sharpness: ::Integer }, the 3rd error around Ruby::UnresolvedOverloading disappears, even though the type orderings produce the same intersection result.
What is happening here? Am I using intersections in the wrong way? If so, how do we combine two types into a superset type? i.e. { ?a: Integer } & { ?b: String } => { ?a: Integer, ?b: String }
The text was updated successfully, but these errors were encountered:
Confirming that this issue is still present in the newly released 1.9 version. The "UnresolvedOverloading" error is no longer present when I move modelsItemsBaseAttrs to the start or end of the type union, but the "IncompatibleAssignment" error is still present, and "FallbackAny" has been replaced by a "UnannotatedEmptyCollection" error.
app/models/items/sword.rb:14:29: [error] Empty hash doesn't have type annotation
│ Diagnostic ID: Ruby::UnannotatedEmptyCollection
│
└ def initialize(attrs = {})
~~
app/models/items/sword.rb:14:21: [error] Cannot assign a value of type `::Hash[untyped, untyped]` to an expression of type `::modelsItemsSwordAttrs`
│ ::Hash[untyped, untyped] <: ::modelsItemsSwordAttrs
│ ::Hash[untyped, untyped] <: (::modelsItemsBaseAttrs & { ?:sharpness => ::Integer })
│ ::Hash[untyped, untyped] <: ::modelsItemsBaseAttrs
│ ::Hash[untyped, untyped] <: { ?:durability => ::Integer }
│
│ Diagnostic ID: Ruby::IncompatibleAssignment
│
└ def initialize(attrs = {})
Seems like Steep might be joining/operating on RBS intersection types incorrectly.
Given the following RBS:
and this implementation:
I should not be seeing any errors, but steep is returning the following:
Weird things:
Ruby::FallbackAny
when clearly it is a hash, both the default value and the typingmodelsItemsBaseAttrs
to the front of the intersection fortype modelsItemsSwordAttrs
, i.e.type modelsItemsSwordAttrs = modelsItemsBaseAttrs & { ?sharpness: ::Integer }
, the 3rd error around Ruby::UnresolvedOverloading disappears, even though the type orderings produce the same intersection result.What is happening here? Am I using intersections in the wrong way? If so, how do we combine two types into a superset type? i.e.
{ ?a: Integer } & { ?b: String }
=>{ ?a: Integer, ?b: String }
The text was updated successfully, but these errors were encountered: