Elm Exactly
Results / elm /

AliasProblemExtensibleRecordUnitTupleAndFunctionTest

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.

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 faillamdera-1.5.0 fail
A type alias that refers to itself inside an extensible record is rejected with an ALIAS PROBLEM.

`A r` is an extensible record whose field `f` holds a tuple of a unit, an `A r`
(parenthesised around a block comment) and a function returning `A r`. A type alias
cannot be recursive, so the compiler must report the self-reference.

Results

elm-0.19.1

pass
Output
Compiling ...-- ALIAS PROBLEM -- src/AliasProblemExtensibleRecordUnitTupleAndFunctionTest.elm

This type alias is recursive, forming an infinite type!

16| type alias A r = { r | f : ( (), ( {- A -} A r ), Int -> A r ) }
               ^
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 r =
        A
            { r | f : ( (), A r, Int -> A r ) }

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

pass
Output
Compiling ...-- ALIAS PROBLEM -- src/AliasProblemExtensibleRecordUnitTupleAndFunctionTest.elm

This type alias is recursive, forming an infinite type!

16| type alias A r = { r | f : ( (), ( {- A -} A r ), Int -> A r ) }
               ^
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 r =
        A
            { r | f : ( (), A r, Int -> A r ) }

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

fail
compiler killed by SIGSEGV
Dependencies ready!
Compiling ...

lamdera-1.5.0

fail
Missing 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 AliasProblemExtensibleRecordUnitTupleAndFunctionTest)

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 AliasProblemExtensibleRecordUnitTupleAndFunctionTest)

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm/AliasProblemExtensibleRecordUnitTupleAndFunctionTest] in its title.

Source

The -- CHECK: lines give the expected output.

module AliasProblemExtensibleRecordUnitTupleAndFunctionTest exposing (..)
{-| A type alias that refers to itself inside an extensible record is rejected with an ALIAS PROBLEM.
`A r` is an extensible record whose field `f` holds a tuple of a unit, an `A r`
(parenthesised around a block comment) and a function returning `A r`. A type alias
cannot be recursive, so the compiler must report the self-reference.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, modules-alias-not-recursive
-- COMPILE-ERROR: ALIAS PROBLEM, extensible record, unit, tuple and function
-- CHECK: -- ALIAS PROBLEM -
type alias A r = { r | f : ( (), ( {- A -} A r ), Int -> A r ) }

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_AliasProblemExtensibleRecordUnitTupleAndFunctionTest, 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.