-
-
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
Generic inheritance is broken #2665
Comments
I'll keep this issue open for now, until we test it a bit more, but all or most of the bugs above are now fixed on master. |
I'm not really sure about this example, should this work or not? |
@benoist what seems to be the problem in that example? |
Ah sorry I should have explained it a bit better. I'd expected that adding 2 Int32Arrays it would also return an Int32Array. This is currently not the case |
Well, Anyhow, if you do believe it should, or have a similar issue, please open a new issue here; the idea of this one is to act as an "index" of generic-related stuff. |
No I think I agree with you. If I want it to return a concatenation of self I should explicitly do so. |
That's what I was going to suggest: either composition, or just declaring an alias if what you want is to have a friendlier name for a particular instantiation of a generic. |
Would further bug reports regarding generic inheritance be useful, or just noise at this point? |
@ezrast Bug reports are always welcome |
Could we |
This issue should be closed and made a project or label. |
#codetriage |
@miketheman, The kernel of the issue, that "the current implementation is very weak and needs a redesign", has not yet been addressed to my knowledge. Several related bugs remain in latest Crystal, such as #4059 (which was closed as a duplicate of this issue), #5290, and this: module Base(T); end
module Derived; extend Base(Int32); end
arr = [Derived] of Base(Int32)
pp arr.first == arr.first # false
pp Derived == arr.first # false
pp arr.first == Derived # true |
@ezrast please open as a seperate issue, that code shouldn't compile as |
Considering there's a new issue to track the |
@miketheman As far as I can see lot of issues have been closed (without resolution) in favor of this one, so it's kinda recursive situation. Closing this will leave 'em forgotten for the future. |
I reviewed every linked issue after #2665 (comment) and it seems the only ones that still break on master are #4086, #6760, and #10133. So once these are fixed I think we should close this meta-issue and rely on the |
I have re-opened those individual issues. It's probably easier to target them directly in upcoming PRs (in case a PR spans multiple, that works as well). |
Right now inheriting from generic types, and even inheriting a non-generic type that's not
Reference
is broken. There are many issues related to this, which I'll link here:macro inherited
work with generics? #1793 How does macroinherited
work with genericsAnd one pending decision:
All of these should be fixed. The main issue is that the current implementation is very weak and needs a redesign. This is only a matter of time.
This issue will be used to mark all bugs related to generics as a duplicate of this one, because it's essentially one problem.
The text was updated successfully, but these errors were encountered: