Diagnostic and cause
LinkImport cycle
- Family
- topaz
- Phase
- resolve
- Code
TPZ3006
Cause and conditions
A directed cycle in the module import graph produces TPZ3006.
Related rule: Trigger and repairResponse
Remove a dependency from the cycle or put shared declarations in a third module that both modules can import.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 387-395 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 487-487 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 466-525 - TPZ3006 at
151141d7bb44
Compiler phase: resolve.
Compiler explanation: The module graph contains a cyclic import dependency.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ3006]: import cycle: first -> second -> first
The import graph leads back to a module already on the dependency path. The example forms first -> second -> first.
Trigger and repair
A directed cycle in the module import graph produces TPZ3006.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 466-525 - TPZ3006 at
151141d7bb44
Response
LinkRemove a dependency from the cycle or put shared declarations in a third module that both modules can import.
Reproduction and verification
LinkRejected program
Linkimport first
No stdout.
import secondexport let one = 1
import firstexport let two = 2
Expected result
The expected diagnostic, cause, source location, and accompanying diagnostics are specified below. The verification status records whether this program has been run.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 387-395 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 487-487 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 466-525 - TPZ3006 at
151141d7bb44
Corrected program
Linkimport first
import secondexport let one = 1
export let two = 2
Expected result
Expected result
Checking accepts the program. Exit code 0.
This program applies the repair described above. The verification status records whether it has been run.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 466-525 - TPZ3006 at
151141d7bb44