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
This is actually an improvement over 0.18.7, so a fix. If you try it without generic types you'll see that you get a similar error. Whenever you mix two types in the same hierarchy you will get a "virtual type" of the base type. And there's no success? method on Try. You can make Try abstract to make it compile, which is also more correct code as you don't want Try to be instantiated by users.
Well, I agree that the compiler has same type inference logic for all cases. Improvement or not is a different problem. So, I'll comment it on another issue when I have a chance.
I'm writing
Try
monad that inherits from generic class.https://github.com/maiha/try.cr/blob/master/src/try.cr
This works on until 0.18.x but fails on 0.19.x.
Minimum reproducible code
0.18.7
% crystal -v Crystal 0.18.7 [68783f1] (2016-07-03) % crystal test.cr true
0.19.4
It looks like #3423
but, failed on master branch too.
master(e019442)
guess
When we directly specify the subclass, it works on 0.19.x.
Success(Int32).new(1).success? # => true
So, it would be a some problem on
def self.try : Success(T) | Failure(T)
about type inference.Thanks.
The text was updated successfully, but these errors were encountered: