Elm Exactly
Results / elm /

CompilerIssue2027IncompatibleExtensibleRecordsHangTest

Tags:elm19-bugelm-spec

Checks, in A Standard Definition of Elm?:rule s-exp-apprule s-ty-openrecord

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 pass

Issue: elm/compiler#2027

Using one value as two incompatible extensible records (`Tricky x x`) must be a type error.

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

The program is ill-typed, so it must be rejected with a type error. Elm 0.19.1 instead hangs while
its memory grows without bound, or crashes.

Results

elm-0.19.1

fail
compiler used more than 4096 MB of memory
Dependencies ready!
Compiling ...

elm-0.19.2

fail
compiler used more than 4096 MB of memory
Dependencies ready!
Compiling ...

elm-0.19.3

fail
compiler used more than 4096 MB of memory
Dependencies ready!
Compiling ...

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- TYPE MISMATCH - src/CompilerIssue2027IncompatibleExtensibleRecordsHangTest.elm

The 2nd argument to `Tricky` is not what I expect:

26|     Tricky x x
                 ^
This `x` value is a:

    { r | a : Int }

But `Tricky` needs the 2nd argument to be:

    { r | b : Int }

Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module CompilerIssue2027IncompatibleExtensibleRecordsHangTest exposing (main)
{-| Using one value as two incompatible extensible records (`Tricky x x`) must be a type error.
<https://github.com/elm/compiler/issues/2027>
The program is ill-typed, so it must be rejected with a type error. Elm 0.19.1 instead hangs while
its memory grows without bound, or crashes.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-exp-app, s-ty-openrecord
-- COMPILE-ERROR: a type error, not a hang
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: HasCallStack
import Html
type Tricky r
= Tricky { r | a : Int } { r | b : Int }
mkTricky x =
Tricky x x
main =
Html.text ""

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_CompilerIssue2027IncompatibleExtensibleRecordsHangTest, in StandardElmMech/Certs/). The proved inference W fails on a module of the program, and W fails only where no derivation exists (plan step 11) (Stat.not_legal_of_wRefutes). It holds for every derivation, with no hypothesis about principality.