CompilerIssue1866PhantomExtensibleRecordHangTest
Checks, in A Standard Definition of Elm?:rule s-exp-apprule s-valbind-var
Not translated into Lean for the mechanisation of the book: see why.
Issue: elm/compiler#1866
Composing two functions on phantom types over different extensible records, taken from one record argument, is rejected with a type error. <https://github.com/elm/compiler/issues/1866> Elm 0.19.1 hangs on it, its memory growing without bound, instead of reporting the error.
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
passOutput
Detected problems in 1 module.
-- TYPE MISMATCH ------ src/CompilerIssue1866PhantomExtensibleRecordHangTest.elm
The 1st argument to `bug` is not what I expect:
37| bug (\with -> Phantom |> with.f1 |> with.f2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This argument is an anonymous function of type:
{ f1 : Phantom { r | a1 : () } -> Phantom { r | a1 : () }
, f2 : Phantom { r | a1 : () } -> b
}
-> b
But `bug` needs the 1st argument to be:
{ f1 : Phantom { r | a1 : () } -> Phantom { r | a1 : () }
, f2 : Phantom { r | a2 : () } -> Phantom { r | a2 : () }
}
-> Html msg
-- TYPE MISMATCH ------ src/CompilerIssue1866PhantomExtensibleRecordHangTest.elm
Something is off with the body of the `bug` definition:
32| ()
^^
The body is a unit value:
()
But the type annotation on `bug` says it should be:
Html msg
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CompilerIssue1866PhantomExtensibleRecordHangTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue1866PhantomExtensibleRecordHangTest exposing (main)
{-| Composing two functions on phantom types over different extensible records, taken from one record argument, is rejected with a type error.
<https://github.com/elm/compiler/issues/1866>
Elm 0.19.1 hangs on it, its memory growing without bound, instead of reporting the error.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-exp-app, s-valbind-var
-- COMPILE-ERROR: a type error, not a hang
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: HasCallStack
import Html exposing (Html)
type Phantom s
= Phantom
bug :
({ f1 : Phantom { r | a1 : () } -> Phantom { r | a1 : () }
, f2 : Phantom { r | a2 : () } -> Phantom { r | a2 : () }
}
-> Html msg
)
-> Html msg
bug configure =
()
main : Html msg
main =
bug (\with -> Phantom |> with.f1 |> with.f2)
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_CompilerIssue1866PhantomExtensibleRecordHangTest, 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.