Elm Exactly
Results / elm /

CompilerIssue2148RecordUpdateFoldrCrashTest

Tags:elm19-bugelm-spec

Checks, in A Standard Definition of Elm?:rule s-atpat-recordrule s-atexp-updaterule s-exp-app

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

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

Issue: elm/compiler#2148

A type error in a `foldr` over records must be reported normally, not crash the compiler.

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

Elm 0.19.1 crashes with "Data/Vector/Generic/Mutable.hs:703 (modify): index out of bounds (3,3)"
and "thread blocked indefinitely in an MVar operation". `Model` is `{}`, so `model.a` is a type
error that must be reported normally.

The issue's own program used the library function `List.foldr`; this version reproduces the same
bug with a local `foldr` of the same type in its place.

Results

elm-0.19.1

fail
Unexpected pattern (CHECK-NOT): HasCallStack
--- compiler output ---
Dependencies ready!
Compiling ...elm: ./Data/Vector/Generic/Mutable.hs:703 (modify): index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at ./Data/Vector/Internal/Check.hs:87:5 in vector-0.12.0.3-c437ec060b3fdd8eecce3c5fd7ada7fe6d6f6ed56dbc08f484769fe155c657df:Data.Vector.Internal.Check

-- 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
Unexpected pattern (CHECK-NOT): HasCallStack
--- compiler output ---
Dependencies ready!
Compiling ...elm: index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at src/Data/Vector/Internal/Check.hs:103:12 in vector-0.13.2.0-c5f5d3d65d4bbfa8d70b583d7f12b14f53d5d0d4dd455f21b70f9090be728c57:Data.Vector.Internal.Check
  checkError, called at src/Data/Vector/Internal/Check.hs:109:17 in vector-0.13.2.0-c5f5d3d65d4bbfa8d70b583d7f12b14f53d5d0d4dd455f21b70f9090be728c57:Data.Vector.Internal.Check
  check, called at src/Data/Vector/Internal/Check.hs:122:5 in vector-0.13.2.0-c5f5d3d65d4bbfa8d70b583d7f12b14f53d5d0d4dd455f21b70f9090be728c57:Data.Vector.Internal.Check
  checkIndex, called at src/Data/Vector/Generic/Mutable.hs:680:16 in vector-0.13.2.0-c5f5d3d65d4bbfa8d70b583d7f12b14f53d5d0d4dd455f21b70f9090be728c57:Data.Vector.Generic.Mutable
  modify, called at src/Data/Vector/Mutable.hs:471:10 in vector-0.13.2.0-c5f5d3d65d4bbfa8d70b583d7f12b14f53d5d0d4dd455f21b70f9090be728c57:Data.Vector.Mutable

-- 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
Unexpected 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:

>   index out of bounds (3,3)
>   CallStack (from HasCallStack):
>     error, called at src/Data/Vector/Internal/Check.hs:103:12 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Internal.Check
>     checkError, called at src/Data/Vector/Internal/Check.hs:109:17 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Internal.Check
>     check, called at src/Data/Vector/Internal/Check.hs:122:5 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Internal.Check
>     checkIndex, called at src/Data/Vector/Generic/Mutable.hs:680:16 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Generic.Mutable
>     modify, called at src/Data/Vector/Mutable.hs:471:10 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Mutable (in module CompilerIssue2148RecordUpdateFoldrCrashTest)

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: index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at src/Data/Vector/Internal/Check.hs:103:12 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Internal.Check
  checkError, called at src/Data/Vector/Internal/Check.hs:109:17 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Internal.Check
  check, called at src/Data/Vector/Internal/Check.hs:122:5 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Internal.Check
  checkIndex, called at src/Data/Vector/Generic/Mutable.hs:680:16 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Generic.Mutable
  modify, called at src/Data/Vector/Mutable.hs:471:10 in vector-0.13.2.0-819adc4b11fd7903b8229c2d47e9bd07b3010ceaa3c96251df84e2c2ffaae8c6:Data.Vector.Mutable (in module CompilerIssue2148RecordUpdateFoldrCrashTest)
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
Unexpected pattern (CHECK-NOT): HasCallStack
--- 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:

>   index out of bounds (3,3)
>   CallStack (from HasCallStack):
>     error, called at src/Data/Vector/Internal/Check.hs:103:12 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Internal.Check
>     checkError, called at src/Data/Vector/Internal/Check.hs:109:17 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Internal.Check
>     check, called at src/Data/Vector/Internal/Check.hs:122:5 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Internal.Check
>     checkIndex, called at src/Data/Vector/Generic/Mutable.hs:680:16 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Generic.Mutable
>     modify, called at src/Data/Vector/Mutable.hs:471:10 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Mutable (in module CompilerIssue2148RecordUpdateFoldrCrashTest)

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: index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at src/Data/Vector/Internal/Check.hs:103:12 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Internal.Check
  checkError, called at src/Data/Vector/Internal/Check.hs:109:17 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Internal.Check
  check, called at src/Data/Vector/Internal/Check.hs:122:5 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Internal.Check
  checkIndex, called at src/Data/Vector/Generic/Mutable.hs:680:16 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Generic.Mutable
  modify, called at src/Data/Vector/Mutable.hs:471:10 in vector-0.13.2.0-84e73661f62250b722270a89126c1b6f824733fcbba5c042f1fb3f3870f21dc8:Data.Vector.Mutable (in module CompilerIssue2148RecordUpdateFoldrCrashTest)
Dependencies ready!

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module CompilerIssue2148RecordUpdateFoldrCrashTest exposing (main)
{-| A type error in a `foldr` over records must be reported normally, not crash the compiler.
<https://github.com/elm/compiler/issues/2148>
Elm 0.19.1 crashes with "Data/Vector/Generic/Mutable.hs:703 (modify): index out of bounds (3,3)"
and "thread blocked indefinitely in an MVar operation". `Model` is `{}`, so `model.a` is a type
error that must be reported normally.
The issue's own program used the library function `List.foldr`; this version reproduces the same
bug with a local `foldr` of the same type in its place.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-atpat-record, s-atexp-update, s-exp-app
-- 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 alias A =
{ ap1 : String }
type alias B =
{ bp1 : String }
type alias Model =
{}
foldr : (a -> b -> b) -> b -> List a -> b
foldr f acc list =
case list of
[] ->
acc
x :: rest ->
f x (foldr f acc rest)
f1 : Model -> Model
f1 model =
let
( a, b ) =
foldr
(\x ( a2, list ) ->
case x.d of
Nothing ->
( a2, x :: list )
Just c ->
let
c2 =
{ c | p1 = c.p1 + 1 }
x2 =
{ x | c = Just c2 }
( a3, x3 ) =
f2 a2 x2
in
( a3, x3 :: list )
)
( model.a, [] )
model.b
in
{ model | a = a, b = b }
f2 : A -> B -> ( A, B )
f2 x y =
( x, y )

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