-
-
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
Cross-require causes the problems with inheritance #6462
Comments
module requires network_module, before defining Module. This is working as expected, it's not a bug. Define Module before requiring the other file. |
No, it's definitely a bug! |
Order of definition does matter in Crystal. This is not D nor Java. Im Crystal you can define a class, define another class, then reopen the first one and add whatever you need to it. This is sometimes called forward declaration in other languages. You sometimes need it in Crystal (you need it here). |
Sorry I don't provide code, I'm on a cellphone. |
Should we close this? Could/should we make this possible for at least non-macro defined classes. |
Yes, the double definition of the parent class has solved the problem. |
Simple cross-require code with two abstract classes causes the inheritance problem.
Project structure:
Module and NetworkModule are both abstract classes. NetworkModule extends Module. The Module class also has the static method that loads NetworkModule's subclasses into its hash.
Here is the code:
The compiler reports this error:
The text was updated successfully, but these errors were encountered: