Elm Exactly
Results / elm /

CompilerIssue2036LensRecordUpdateHangTest

Tags:elm19-bugelm-spec

Checks, in A Standard Definition of Elm?:rule s-exp-apprule s-atexp-updaterule sm-typbind-record

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#2036

A lens whose setter takes its arguments in the wrong order must be a type error.

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

`set` is declared `b -> a -> a`, but the lambda takes the record first, so the program is
ill-typed and 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

fail
compiler used more than 4096 MB of memory
Verifying dependencies (10/10)

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module CompilerIssue2036LensRecordUpdateHangTest exposing (main)
{-| A lens whose setter takes its arguments in the wrong order must be a type error.
<https://github.com/elm/compiler/issues/2036>
`set` is declared `b -> a -> a`, but the lambda takes the record first, so the program is
ill-typed and 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-atexp-update, sm-typbind-record
-- COMPILE-ERROR: a type error, not a hang
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: HasCallStack
import Html
type alias Lens a b =
{ get : a -> b
, set : b -> a -> a
}
type alias State inputState =
{ input : inputState }
inputLens : Lens (State inputState) inputState
inputLens =
Lens .input (\a b -> { a | input = b })
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_CompilerIssue2036LensRecordUpdateHangTest, 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.