ImportCycleTest
Tags:elm-spec
Checks, in A Standard Definition of Elm?:restriction program-import-order
Not translated into Lean for the mechanisation of the book: see why.
Modules may not import each other in a cycle. A Standard Definition of Elm?, restriction program-import-order: each module of a program imports only modules of the initial basis and modules that stand before it in the program, so there is no order for `ImportCycleA` and `ImportCycleB`, which import each other. <https://elm-test-suite.netlify.app/standard/restrictions/program-import-order>
Results
elm-0.19.1
passOutput
Compiling ...-- IMPORT CYCLE ----------------------------------------------------------------
Your module imports form a cycle:
┌─────┐
│ ImportCycleB
│ ↓
│ ImportCycleA
└─────┘
Learn more about why this is disallowed and how to break cycles
here:<https://elm-lang.org/0.19.1/import-cycles>
Detected a problem.
elm-0.19.2
passOutput
Compiling ...-- IMPORT CYCLE ----------------------------------------------------------------
Your module imports form a cycle:
┌─────┐
│ ImportCycleB
│ ↓
│ ImportCycleA
└─────┘
Learn more about why this is disallowed and how to break cycles
here:<https://elm-lang.org/0.19.2/import-cycles>
Detected a problem.
elm-0.19.3
passOutput
Compiling ...-- IMPORT CYCLE ----------------------------------------------------------------
Your module imports form a cycle:
┌─────┐
│ ImportCycleB
│ ↓
│ ImportCycleA
└─────┘
Learn more about why this is disallowed and how to break cycles here:
<https://elm-lang.org/0.19.3/import-cycles>
Detected a problem.
lamdera-1.5.0
passOutput
-- ERROR -----------------------------------------------------------------------
lamdera-1.5.0-0.19.3-linux-x86_64-1ec0a3a092ea4c714f98404cd529abe37b0673e0 (Mon
Oct 26 11:38:05 2026 +1100) (branch:distribute)
I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:
> Crash {_module = Module "Graph", _name = Name "Graph.withMinimalCycle", _line = Line 273, _message = "bug in RootSelector when calculating minimal cycle"}
These errors are usually pretty confusing, so start by asking around on Discord
https://dashboard.lamdera.app/docs/discuss to see if anyone can get you unstuck
quickly.
-- REQUEST ---------------------------------------------------------------------
If you are feeling up to it, please try to get your code down to the smallest
version that still triggers this message. Ideally in a single Main.elm and
elm.json file.
From there open a NEW issue at https://github.com/elm/compiler/issues with your
reduced example pasted in directly. (Not a link to a repo or gist!) Do not worry
about if someone else saw something similar. More examples is better!
This kind of error is usually tied up in larger architectural choices that are
hard to change, so even when we have a couple good examples, it can take some
time to resolve in a solid way.lamdera: Crash {_module = Module "Graph", _name = Name "Graph.withMinimalCycle", _line = Line 273, _message = "bug in RootSelector when calculating minimal cycle"}
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/ImportCycleTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ImportCycleTest exposing (main)
{-| Modules may not import each other in a cycle.
A Standard Definition of Elm?, restriction program-import-order: each module of a program imports
only modules of the initial basis and modules that stand before it in the program, so there is
no order for `ImportCycleA` and `ImportCycleB`, which import each other.
<https://elm-test-suite.netlify.app/standard/restrictions/program-import-order>
-}
-- TAGS: elm-spec, program-import-order
-- COMPILE-ERROR: two modules that import each other
-- CHECK: {{-- [A-Z ]+ -}}
import Html
import ImportCycleA
main =
let
_ =
Debug.log "a" ImportCycleA.a
in
Html.text "done"
Lean translation
No reduced program for Lean's evaluator: the test expects a compile error, so it has no meaning to evaluate. Lean has the program as written, in source syntax, and proves what the static semantics says of it (below). See the Lean mechanisation for which tests are in Lean, and why.
Static semantics: Lean proves that the program as written is not legal, so a compiler must reject it (refuse_elm_ImportCycleTest, in StandardElmMech/Certs/). The program breaks a syntactic restriction, which the kernel checks on its syntax tree; no type inference is involved (Stat.not_legal_of_syn): res:program-import-order. It holds for every derivation, with no hypothesis about principality.