Elm Exactly
Results / elm /

CompilerIssue2182ExtensibleFunctionAliasCrashTest

Tags:elm19-bugelm-spec

Checks, in A Standard Definition of Elm?:rule s-ty-conrule sm-typbindsection Types and Type Functions

Not translated into Lean for the mechanisation of the book: see why.

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass

Issue: elm/compiler#2182

An alias that extends its parameter with a field the parameter already has is not a type.

<https://github.com/elm/compiler/issues/2182>

With `type alias Goal a = { a | field : Int } -> a`, Elm 0.19.1 accepts
`solution : Goal { field : Int }` / `solution = identity`, the outer `field` winning, but crashes
with "Map.!: given key is not an element in the map" on `puzzle rec = rec`, which is the same
function.

A Standard Definition of Elm?, ruling A23: a record row has unique labels, and a row variable
ranges only over rows that lack the labels already present. `Goal { field : Int }` would give the
record a second `field`, so the substitution is not defined, the alias cannot be applied, and
neither annotation elaborates. The program must be refused, with no crash.
<https://elm-test-suite.netlify.app/standard/static-core#sec-static-core-types>

Results

elm-0.19.1

pass
Output
Verifying dependencies (10/10)elm: Map.!: given key is not an element in the map
CallStack (from HasCallStack):
  error, called at libraries/containers/Data/Map/Internal.hs:610:17 in containers-0.5.11.0:Data.Map.Internal
Dependencies ready!
Compiling ...
-- ERROR -----------------------------------------------------------------------

I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:

>   thread blocked indefinitely in an MVar operation

These errors are usually pretty confusing, so start by asking around on one of
forums listed at https://elm-lang.org/community 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.elm: thread blocked indefinitely in an MVar operation

elm-0.19.2

pass
Output
Dependencies ready!
Compiling ...elm: Map.!: given key is not an element in the map
CallStack (from HasCallStack):
  error, called at libraries/containers/containers/src/Data/Map/Internal.hs:622:17 in containers-0.6.8-b28e:Data.Map.Internal

-- ERROR -----------------------------------------------------------------------

I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:

>   thread blocked indefinitely in an MVar operation

These errors are usually pretty confusing, so start by asking around on one of
forums listed at https://elm-lang.org/community 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.elm: thread blocked indefinitely in an MVar operation

elm-0.19.3

pass
Output
Verifying dependencies (10/10)
Dependencies ready!
Compiling ...--------------------------------------

I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:

>   unable to find "a"
>   
>   Type.Instantiate.fromSrcType (line 73) (in module CompilerIssue2182ExtensibleFunctionAliasCrashTest)

These errors are usually pretty confusing, so start by asking around on one of
forums listed at https://elm-lang.org/community 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.elm: unable to find "a"

Type.Instantiate.fromSrcType (line 73) (in module CompilerIssue2182ExtensibleFunctionAliasCrashTest)
HasCallStack backtrace:
  collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
  toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
  throw, called at builder/src/Reporting.hs:445:45 in elm-0.19.3-inplace-elm:Reporting


lamdera-1.5.0

pass
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 "Type.Instantiate", _name = Name "Type.Instantiate.fromSrcType", _line = Line 97, _message = "unable to find \"a\""} (in module CompilerIssue2182ExtensibleFunctionAliasCrashTest)

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 "Type.Instantiate", _name = Name "Type.Instantiate.fromSrcType", _line = Line 97, _message = "unable to find \"a\""} (in module CompilerIssue2182ExtensibleFunctionAliasCrashTest)

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module CompilerIssue2182ExtensibleFunctionAliasCrashTest exposing (main)
{-| An alias that extends its parameter with a field the parameter already has is not a type.
<https://github.com/elm/compiler/issues/2182>
With `type alias Goal a = { a | field : Int } -> a`, Elm 0.19.1 accepts
`solution : Goal { field : Int }` / `solution = identity`, the outer `field` winning, but crashes
with "Map.!: given key is not an element in the map" on `puzzle rec = rec`, which is the same
function.
A Standard Definition of Elm?, ruling A23: a record row has unique labels, and a row variable
ranges only over rows that lack the labels already present. `Goal { field : Int }` would give the
record a second `field`, so the substitution is not defined, the alias cannot be applied, and
neither annotation elaborates. The program must be refused, with no crash.
<https://elm-test-suite.netlify.app/standard/static-core#sec-static-core-types>
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-ty-con, sm-typbind, sec:static-core-types
-- COMPILE-ERROR: a row extended with a label it already has
-- CHECK: {{-- [A-Z ]+ -}}
import Html exposing (text)
type alias Goal a =
{ a | field : Int } -> a
solution : Goal { field : Int }
solution =
identity
puzzle : Goal { field : Int }
puzzle rec =
rec
main =
let
_ =
( solution, puzzle )
in
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_CompilerIssue2182ExtensibleFunctionAliasCrashTest, in StandardElmMech/Certs/). Some type expression of the program (an alias, a constructor's argument, an annotation, a port) elaborates in no derivation (Stat.not_legal_of_typesFailB). It holds for every derivation, with no hypothesis about principality.