-
-
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
Inheriting from generic class/struct ignoring the type causes segmentation fault #1944
Comments
This code as-is just doesn't make much sense. Consider this: struct Generic(T)
def foo
T.new
end
end
struct IgnoreType < Generic(T)
end
p IgnoreType.new.foo # What is this? (segfaults) This should fail compilation with a "Unknown identifier T". |
Hm, that should give a compile error right at the definition of |
Of course that code only makes sense if no method that uses A possible use case would be trying to define an abstract struct Option(T)
end
struct Some(T) < Option(T)
def initialize(@value : T)
end
end
struct None < Option(T)
end Now, I'm not saying that this should work, I could totally imagine this not being possible (and in fact this kind of programming is not very Crystal-idiomatic I think), but then it should be a compilation error. An important detail that I forgot to add is that the segmentation fault happens in the compiler, that's why I thought it is a bug worth reporting:
|
Seems fixed as of v16.
|
I'm sure it fails with a class though |
Indeed it does. |
Closed in favor of #2665 |
I'm guessing that is not allowed (although I run into a case where it would be useful), but should probably give a compilation error:
Code:
The same happens if they are classes instead of structs.
(if this is allowed, I'd expect both lines to print
true
, and if it's not, a compilation error)The text was updated successfully, but these errors were encountered: