CompilerIssue2214LensSetterArgumentOrderHangTest
Checks, in A Standard Definition of Elm?:rule s-atexp-updaterule s-exp-apprule sm-typbind-record
Not translated into Lean for the mechanisation of the book: see why.
Issue: elm/compiler#2214
The compiler rejects, with a type error, a lens record whose setter takes its arguments in the wrong order.
<https://github.com/elm/compiler/issues/2214>
`Lens Foo Int` needs a setter of type `Int -> Foo -> Foo`, but `fooN` supplies
`\foo n -> { foo | n = n }`, which takes the `Foo` first. Elm 0.19.1 does not report this: it
hangs with memory growing without bound, or crashes.Results
elm-0.19.1
failcompiler used more than 4096 MB of memory Dependencies ready! Compiling ...
elm-0.19.2
failcompiler used more than 4096 MB of memory Dependencies ready! Compiling ...
elm-0.19.3
failcompiler used more than 4096 MB of memory Dependencies ready! Compiling ...
lamdera-1.5.0
failcompiler 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/CompilerIssue2214LensSetterArgumentOrderHangTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue2214LensSetterArgumentOrderHangTest exposing (main)
{-| The compiler rejects, with a type error, a lens record whose setter takes its arguments in the wrong order.
<https://github.com/elm/compiler/issues/2214>
`Lens Foo Int` needs a setter of type `Int -> Foo -> Foo`, but `fooN` supplies
`\foo n -> { foo | n = n }`, which takes the `Foo` first. Elm 0.19.1 does not report this: it
hangs with memory growing without bound, or crashes.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-atexp-update, s-exp-app, 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 Foo =
{ n : Int }
fooN : Lens Foo Int
fooN =
Lens .n (\foo n -> { foo | n = n })
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_CompilerIssue2214LensSetterArgumentOrderHangTest, 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.