steep
steep copied to clipboard
Array type conversion behaves oddly.
For some reason, this is fine:
if path.is_a?(Symbol)
@path = Array(path)
else
@path = Array(path)
end
But this fails:
@path = Array(path)
Exact error:
lib/decode/definition.rb:21:3: [error] Cannot assign a value of type `[(::Symbol | ::Array[::Symbol])]` to a variable of type `::Array[::Symbol]`
│ [(::Symbol | ::Array[::Symbol])] <: ::Array[::Symbol]
│ (::Symbol | ::Array[::Symbol]) <: ::Symbol
│ ::Array[::Symbol] <: ::Symbol
│ ::Object <: ::Symbol
│ ::BasicObject <: ::Symbol
│
│ Diagnostic ID: Ruby::IncompatibleAssignment
│
└ @path = Array(path)
~~~~~~~~~~~~~~~~~~~
The expectation is that path is Symbol | Array[Symbol]. Let me know if you need more details.
This is most likely the root cause: https://github.com/ruby/rbs/issues/1874