-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enumerable(T)#to_a
regression with interface type
#14440
Comments
That's an interesting problem. I suppose the proper way to fix this is to revert the changes to the non-yielding That would still leave a bit of a weird situation that |
Actually, if you put the correct type on So it turns out the actual issue is |
We might want to think about this behaviour of It should be worth to investigat other uses of this method whether it could lead to similar issues in edge cases like this. |
That sounds exactly like #12846 |
I looked for other potential issues in relation to SomeStruct(SomeInterface, 2).new.tally # Error: method SomeStruct(SomeInterface, 2)#tally must return Hash(SomeInterface, Int32) but it is returning Hash(One | Two, Int32) @Blacksmoke16 If you want to add that to #14447, the fix is --- i/src/enumerable.cr
+++ w/src/enumerable.cr
@@ -1970,7 +1970,7 @@ module Enumerable(T)
# ["a", "b", "c", "b"].tally # => {"a"=>1, "b"=>2, "c"=>1}
# ```
def tally : Hash(T, Int32)
- tally_by(&.itself)
+ tally_by(Hash(T, Int32).new, &.itself)
end |
It seems #12653 introduced a regression when calling
#to_a
on an enumerable of a module type. For example,Works fine on 1.10.0
Fails on 1.11.0
The text was updated successfully, but these errors were encountered: