Codes / Error Code 002
Codes / Error Code 002
Error Code 002
Overview
This error occurs when two or more modules depend on each other in a way that forms a cycle, making it impossible for the compiler to resolve the dependencies.
Details
-
Common Causes:
- Module
Aimports moduleB, and moduleBimports moduleA. - Poorly designed interdependencies between modules.
- Module
-
Example:
// a.d
import b;
// b.d
import a; // Error: circular dependency
- Solution: Break the cycle by refactoring the code to eliminate mutual dependencies. Use an intermediary module if necessary.
// c.d (intermediary module)
module c;
import shared_logic;
// a.d
import c;
// b.d
import c;