CompilerIssue2146RoseLambdaPatternCrashTest
Checks, in A Standard Definition of Elm?:rule s-exp-lambdarule s-pat-conrule s-valbind-var
Not translated into Lean for the mechanisation of the book: see why.
Issue: elm/compiler#2146
A type error involving a lambda pattern on a custom type must be reported normally, not crash
the compiler.
<https://github.com/elm/compiler/issues/2146>
In `tail`, the lambda's pattern `Branch _ xs` makes its argument a `Rose`, and `map f xs`
then needs `f`'s argument type `a` to be a `Rose` too, but the annotation makes `a` an arbitrary
type: a type error. Elm 0.19.1 crashes ("? [rank = 1]", Type/Solve.hs:206, "thread blocked
indefinitely in an MVar operation").
The issue's own program used the library function `List.map` in `tail`; this version reproduces
the same bug with a local `map` of the same type in its place.Results
elm-0.19.1
failUnexpected pattern (CHECK-NOT): HasCallStack
--- compiler output ---
Dependencies ready!
Compiling ...elm: You ran into a compiler bug. Here are some details for the developers:
? [rank = 1]
Please create an <http://sscce.org/> and then report it
at <https://github.com/elm/compiler/issues>
CallStack (from HasCallStack):
error, called at compiler/src/Type/Solve.hs:206:15 in main:Type.Solve
-- 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
failUnexpected pattern (CHECK-NOT): HasCallStack
--- compiler output ---
Dependencies ready!
Compiling ...elm: You ran into a compiler bug. Here are some details for the developers:
? [rank = 1]
Please create an <http://sscce.org/> and then report it
at <https://github.com/elm/compiler/issues>
CallStack (from HasCallStack):
error, called at compiler/src/Type/Solve.hs:205:15 in elm-0.19.2-inplace-elm:Type.Solve
-- 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
failUnexpected pattern (CHECK-NOT): HasCallStack
--- compiler output ---
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:
> You ran into a compiler bug. Here are some details for the developers:
>
> ? [rank = 1]
>
> Please create an <http://sscce.org/> and then report it
> at <https://github.com/elm/compiler/issues>
>
>
>
> Type.Solve.isGeneric (line 223) (in module CompilerIssue2146RoseLambdaPatternCrashTest)
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: You ran into a compiler bug. Here are some details for the developers:
? [rank = 1]
Please create an <http://sscce.org/> and then report it
at <https://github.com/elm/compiler/issues>
Type.Solve.isGeneric (line 223) (in module CompilerIssue2146RoseLambdaPatternCrashTest)
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
failUnexpected pattern (CHECK-NOT): bypassed the normal error reporting
--- compiler output ---
Verifying dependencies (10/10)
-- 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.Solve", _name = Name "Type.Solve.isGeneric", _line = Line 224, _message = "You ran into a compiler bug. Here are some details for the developers:\n\n ? [rank = 1]\n\nPlease create an <http://sscce.org/> and then report it\nat <https://github.com/elm/compiler/issues>\n\n"} (in module CompilerIssue2146RoseLambdaPatternCrashTest)
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.Solve", _name = Name "Type.Solve.isGeneric", _line = Line 224, _message = "You ran into a compiler bug. Here are some details for the developers:\n\n ? [rank = 1]\n\nPlease create an <http://sscce.org/> and then report it\nat <https://github.com/elm/compiler/issues>\n\n"} (in module CompilerIssue2146RoseLambdaPatternCrashTest)
Dependencies ready!
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CompilerIssue2146RoseLambdaPatternCrashTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue2146RoseLambdaPatternCrashTest exposing (main)
{-| A type error involving a lambda pattern on a custom type must be reported normally, not crash
the compiler.
<https://github.com/elm/compiler/issues/2146>
In `tail`, the lambda's pattern `Branch _ xs` makes its argument a `Rose`, and `map f xs`
then needs `f`'s argument type `a` to be a `Rose` too, but the annotation makes `a` an arbitrary
type: a type error. Elm 0.19.1 crashes ("? [rank = 1]", Type/Solve.hs:206, "thread blocked
indefinitely in an MVar operation").
The issue's own program used the library function `List.map` in `tail`; this version reproduces
the same bug with a local `map` of the same type in its place.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-exp-lambda, s-pat-con, s-valbind-var
-- COMPILE-ERROR: a type error, not a compiler crash
-- CHECK-NOT: HasCallStack
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: bypassed the normal error reporting
import Html exposing (text)
main =
text "done"
type Rose a
= Branch a (List (Rose a))
type T a b
= T (a -> b)
map : (a -> b) -> List a -> List b
map f list =
case list of
[] ->
[]
x :: rest ->
f x :: map f rest
mapT2 : (b -> c -> d) -> T a b -> T a c -> T a d
mapT2 f (T g) (T h) =
T (\x -> f (g x) (h x))
andMap : T a b -> T a (b -> c) -> T a c
andMap =
mapT2 (|>)
succeed : b -> T a b
succeed x =
T (\_ -> x)
andThen : (b -> T a c) -> T a b -> T a c
andThen f g =
T
(\x ->
let
v =
runT g x
in
runT (f v) x
)
lazy : (() -> T a b) -> T a b
lazy thunk =
succeed () |> andThen thunk
tail : T a b -> T a (List b)
tail (T f) =
T (\(Branch _ xs) -> map f xs)
runT : T a b -> Rose a -> b
runT (T f) tree =
f tree
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_CompilerIssue2146RoseLambdaPatternCrashTest, in StandardElmMech/Certs/). The kernel finds a core of the program's typing constraints that has no solution, so no derivation types it (core refutation, plan step 11) (Stat.not_legal_of_coreRefutes). It holds for every derivation, with no hypothesis about principality.