Elm Exactly
Results / elm /

CompilerIssue1793ComparableTupleLetCrashTest

Tags:elm19-bugelm-spec

Checks, in A Standard Definition of Elm?:rule s-atexp-oprule s-dec-grouprule d-app-basic-apply

Translated into Lean for the mechanisation of the book: see its Lean translation.

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

Issue: elm/compiler#1793

Comparing tuples containing a `comparable` in a let binding crashes the compiler.

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

Elm 0.19.1 crashes ("index out of bounds") on this valid program; it should compile.

Results

elm-0.19.1

fail
compile failed (exit 1):
Dependencies ready!
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
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

fail
compile failed (exit 1):
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
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:

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

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 CompilerIssue1793ComparableTupleLetCrashTest)
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:

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

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 CompilerIssue1793ComparableTupleLetCrashTest)
Dependencies ready!

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module CompilerIssue1793ComparableTupleLetCrashTest exposing (..)
{-| Comparing tuples containing a `comparable` in a let binding crashes the compiler.
<https://github.com/elm/compiler/issues/1793>
Elm 0.19.1 crashes ("index out of bounds") on this valid program; it should compile.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-atexp-op, s-dec-group, d-app-basic-apply
-- CHECK: f 1: True
import Html exposing (text)
f : comparable -> Bool
f x =
let
result =
( 0, x ) < ( 1, x )
in
result
main =
let
_ =
Debug.log "f 1" (f 1)
in
text "done"

Lean translation

This program is translated into Lean by the translator of the Lean mechanisation of A Standard Definition of Elm?: the program it is, its modules in the reduced syntax of Chapter 7 with every integer constant at Int or Float by number specialisation, and its CHECK lines as written (g_elm_CompilerIssue1793ComparableTupleLetCrashTest, in StandardElmMech/Generated/Elm_CombinatorSP.lean). Lean's evaluator runs the program by the rules of Chapters 7 and 9, and its checks become one generated theorem: some derivation of the program has a log that meets every check, or, for a test that stops at Debug.todo, the program has no meaning.

CheckExpected (CHECK)Lean evaluatorProved by
f 1TrueTruet_elm_CompilerIssue1793ComparableTupleLetCrashTest
/-- tests/elm/src/CompilerIssue1793ComparableTupleLetCrashTest.elm -/
def g_elm_CompilerIssue1793ComparableTupleLetCrashTest : Program := {
  name := "CompilerIssue1793ComparableTupleLetCrashTest", source := "tests/elm/src",
  exposing := .all, imports := [⟨"Html", "Html", some (.items [.var "text"])⟩],
  types := [],
  aliases := [],
  defs := [
    .fn "f" [pv "x"] (letDefs [.fn "result" [] (bin "<" (tup2 (.atexp (.scon (.intF 0))) (v "x")) (tup2 (.atexp (.scon (.intF 1))) (v "x")))] (v "result")),
    .fn "main" [] (letDefs [.pat pw (ap (qv "Debug" "log") [str "f 1", .atexp (.paren (ap (v "f") [.atexp (.scon (.intF 1))]))])] (ap (v "text") [str "done"])) ],
  checks := [
    chk .check "f 1: True" .data ] }

Reading the translation: v "x" is the variable x, c "K" the constructor K, i 42 the integer 42 at Int, .scon (.intF 2) the integer 2 at Float, and str "s" a string; ap f [a, b] applies f to a and then b, and bin "+" a b is a + b. lams, caseOf, ifte, listE, tup2 and recE build lambdas, case, if, lists, pairs and records by the book's derived forms; pv, pw and pcon are variable, wildcard and constructor patterns. defs are the program's top-level definitions and locals the other declarations of main's let, placed in a let around each check; ckk label value kind exp is one check. A name with $ (incF$Float) is a copy number specialisation made.

Static semantics (Chapters 4, 5 and 9): legal_elm_CompilerIssue1793ComparableTupleLetCrashTest states that the program as written is legal, with no hypothesis: the proved inference W gives each module a principal derivation, which meets the syntactic restrictions and the further restrictions, with a type of main Chapter 9 allows. End to end: spec_elm_CompilerIssue1793ComparableTupleLetCrashTest states that Lean computes the reduced program above from the source (derived forms, inference, the proved checker, number specialisation, type erasure), so the theorems about it do not trust the translator's elaboration ([elab]); mean_elm_CompilerIssue1793ComparableTupleLetCrashTest states that the program has a meaning by r:p-program, with both premises, and ident_elm_CompilerIssue1793ComparableTupleLetCrashTest that its specialisation is unique and is the reduced program above, both with no hypothesis about principality.