Elm Exactly
Results / elm /

CompilerIssue2185PhantomWrapperLetAnnotationTest

Tags:elm19-bugelm-spec-contradicts

XFAIL Expected to fail: the book rejects the program: the annotation x : Wrapper a is more general than its value

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/compiler#2185

A valid `let` annotation with a type variable around a wrapped phantom type compiles and runs.

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

`func` (unannotated) has type `Internal a -> Bool`; its `let` annotation `x : Wrapper a` is fine.
Elm 0.19.1 crashes ("You ran into a compiler bug ... a [rank = 2]", Type/Solve.hs:206, then
"thread blocked indefinitely in an MVar operation"). It should compile.

A Standard Definition of Elm? does not accept this as a bug. `func` is unannotated, so the `a` of
the annotation `x : Wrapper a` is a variable of that annotation alone, and `x` must have exactly
the type `Wrapper a` with `a` uninstantiated (rule s-valbind-var). Its value `Wrapper internal`
has the type `Wrapper b`, where `b` is the type of `func`'s argument: the annotation is more
general than the value, or `a` would escape it. The program is rejected; that Elm 0.19.1 crashes
instead of reporting an error is a bug, but not the one this test expects to see fixed.
<https://elm-test-suite.netlify.app/standard/rules/s-valbind-var>

Results

elm-0.19.1

fail
compile failed (exit 1):
Dependencies ready!
Compiling ...elm: You ran into a compiler bug. Here are some details for the developers:

    a [rank = 2]

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

fail
compile failed (exit 1):
Verifying dependencies (10/10)elm: You ran into a compiler bug. Here are some details for the developers:

    a [rank = 2]

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
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.3

fail
compile failed (exit 1):
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:
>   
>       a [rank = 2]
>   
>   Please create an <http://sscce.org/> and then report it
>   at <https://github.com/elm/compiler/issues>
>   
>   
>   
>   Type.Solve.isGeneric (line 223) (in module CompilerIssue2185PhantomWrapperLetAnnotationTest)

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:

    a [rank = 2]

Please create an <http://sscce.org/> and then report it
at <https://github.com/elm/compiler/issues>



Type.Solve.isGeneric (line 223) (in module CompilerIssue2185PhantomWrapperLetAnnotationTest)
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

fail
compile failed (exit 1):
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    a [rank = 2]\n\nPlease create an <http://sscce.org/> and then report it\nat <https://github.com/elm/compiler/issues>\n\n"} (in module CompilerIssue2185PhantomWrapperLetAnnotationTest)

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    a [rank = 2]\n\nPlease create an <http://sscce.org/> and then report it\nat <https://github.com/elm/compiler/issues>\n\n"} (in module CompilerIssue2185PhantomWrapperLetAnnotationTest)
Dependencies ready!

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module CompilerIssue2185PhantomWrapperLetAnnotationTest exposing (main)
{-| A valid `let` annotation with a type variable around a wrapped phantom type compiles and runs.
<https://github.com/elm/compiler/issues/2185>
`func` (unannotated) has type `Internal a -> Bool`; its `let` annotation `x : Wrapper a` is fine.
Elm 0.19.1 crashes ("You ran into a compiler bug ... a [rank = 2]", Type/Solve.hs:206, then
"thread blocked indefinitely in an MVar operation"). It should compile.
A Standard Definition of Elm? does not accept this as a bug. `func` is unannotated, so the `a` of
the annotation `x : Wrapper a` is a variable of that annotation alone, and `x` must have exactly
the type `Wrapper a` with `a` uninstantiated (rule s-valbind-var). Its value `Wrapper internal`
has the type `Wrapper b`, where `b` is the type of `func`'s argument: the annotation is more
general than the value, or `a` would escape it. The program is rejected; that Elm 0.19.1 crashes
instead of reporting an error is a bug, but not the one this test expects to see fixed.
<https://elm-test-suite.netlify.app/standard/rules/s-valbind-var>
-}
-- TAGS: elm19-bug, elm-spec-contradicts
-- XFAIL: the book rejects the program: the annotation x : Wrapper a is more general than its value
-- CHECK: func: True
import Html exposing (text)
type Wrapper a
= Wrapper (Internal a)
type Internal a
= Internal
func internal =
let
x : Wrapper a
x =
Wrapper internal
in
True
main =
let
_ =
Debug.log "func" (func Internal)
in
text "done"