AliasProblemQualifiedTypeTest
Tags:elm19-compile-errorelm-spec
Checks, in A Standard Definition of Elm?:restriction modules-alias-not-recursive
Not translated into Lean for the mechanisation of the book: see why.
A type alias that refers to itself through a qualified type is rejected with an ALIAS PROBLEM. `A` is defined as `Maybe.Maybe (List A)`. Writing the module-qualified name `Maybe.Maybe` does not make the recursion acceptable: a type alias cannot refer to itself.
Results
elm-0.19.1
passOutput
Compiling ...-- ALIAS PROBLEM ------------------------- src/AliasProblemQualifiedTypeTest.elm
This type alias is recursive, forming an infinite type!
15| type alias A = Maybe.Maybe (List A)
^
When I expand a recursive type alias, it just keeps getting bigger and bigger.
So dealiasing results in an infinitely large type! Try this instead:
type A =
A
(Maybe.Maybe (List A))
Hint: This is kind of a subtle distinction. I suggested the naive fix, but I
recommend reading <https://elm-lang.org/0.19.1/recursive-alias> for ideas on how
to do better.
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- ALIAS PROBLEM ------------------------- src/AliasProblemQualifiedTypeTest.elm
This type alias is recursive, forming an infinite type!
15| type alias A = Maybe.Maybe (List A)
^
When I expand a recursive type alias, it just keeps getting bigger and bigger.
So dealiasing results in an infinitely large type! Try this instead:
type A =
A
(Maybe.Maybe (List A))
Hint: This is kind of a subtle distinction. I suggested the naive fix, but I
recommend reading <https://elm-lang.org/0.19.2/recursive-alias> for ideas on how
to do better.
Detected problems in 1 module.
elm-0.19.3
failcompiler killed by SIGSEGV Dependencies ready! Compiling ...
lamdera-1.5.0
failMissing pattern: -- ALIAS PROBLEM -
--- compiler output ---
-- 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"} (in module AliasProblemQualifiedTypeTest)
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"} (in module AliasProblemQualifiedTypeTest)
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/AliasProblemQualifiedTypeTest] in its title.
Source
The -- CHECK: lines give the expected output.
module AliasProblemQualifiedTypeTest exposing (..)
{-| A type alias that refers to itself through a qualified type is rejected with an ALIAS PROBLEM.
`A` is defined as `Maybe.Maybe (List A)`. Writing the module-qualified name
`Maybe.Maybe` does not make the recursion acceptable: a type alias cannot refer to itself.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, modules-alias-not-recursive
-- COMPILE-ERROR: ALIAS PROBLEM, qualified type
-- CHECK: -- ALIAS PROBLEM -
type alias A = Maybe.Maybe (List A)
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_AliasProblemQualifiedTypeTest, 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_modsyn): res:modules-alias-not-recursive. It holds for every derivation, with no hypothesis about principality.