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
Yeah, right now type restrictions and is_a? work a bit different, has to do with covariance and contravariance. This can't lead to a segfault because even thought the restriction lets the type pass, the compiler knows that it's not of that type so it won't let you use it as such.
What should happen in the above code? The fundamental question is "is an Array(Bar) an Array(Foo)?". Well, if you want to read from it than the answer is probably yes. But if you want to write to it (if you want to put a Foo inside an Array(Bar)) then the answer is probably now. A type restriction is currently giving you the first answer, while is_a? is giving you the second answer.
Making both give the second answer would be an easy solution, except that things like a restriction being Range(Int, Int) will break.
I'll open a separate issue for this so we can close all related covariance issues and link to that one.
Expected an error that
{"foo" => {"foo" => "bar"}}
was not aHash(String, RecursiveType)
. Actual:https://play.crystal-lang.org/#/r/1i8m
The case statement doesn't match any branches, but I think it would be possible to get a segfault from this somehow.
Crystal 0.20.3
The text was updated successfully, but these errors were encountered: