On this page
B1006: units depend on each other in a cycle
Catalog status: active. Default severity: error. Stable name: circular-dependency. Family: Names and declarations.
The specifications named in with clauses must not form a cycle (Ada RM 10.1.1): to analyse Alpha, Verada would need Beta, which needs Alpha.
Example (Vada)
with Beta; package Alpha is ... end Alpha;
with Alpha; package Beta is ... end Beta;Example (Varc)
import Beta; package Alpha { ... }
import Alpha; package Beta { ... }
What to do (Vada)
Where one specification needs only the other's types, as the designated types of access types, name it with limited with, which gives its limited view and breaks the cycle:
limited with Beta; package Alpha is ... access Beta.Node ... end Alpha;
with Alpha; package Beta is ... end Beta;Otherwise move what both need into a third package that both with, or move a with from a specification to a body.
What to do (Varc)
Where one package needs only the other's types, as the designated types of access types, name it with limited import, which gives its limited view and breaks the cycle. Otherwise move what both need into a third package that both import, or, when only function bodies use the other package, move its import inside the package's braces, where it is the body's alone.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See names and declarations, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.