CompilerIssue1491PhantomTupleUnsoundTest
Checks, in A Standard Definition of Elm?:rule s-exp-app
Not translated into Lean for the mechanisation of the book: see why.
Issue: elm/compiler#1491
A phantom type parameter `( m, m )` is accepted where `( OnePlus m, m )` is required. <https://github.com/elm/compiler/issues/1491> Elm 0.19.1 accepts `head nil`, although `Vect ( m, m ) a` and `Vect ( OnePlus m, m ) a` do not unify (`m` would have to equal `OnePlus m`). It should report a type error. The issue's own program used the library function `List.head` in `head`; this version reproduces the same bug with a `case` on the list in its place.
Results
elm-0.19.1
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 1 module.
CompilerIssue1491PhantomTupleUnsoundTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/CompilerIssue1491PhantomTupleUnsoundTest.js
elm-0.19.2
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 1 module.
CompilerIssue1491PhantomTupleUnsoundTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/CompilerIssue1491PhantomTupleUnsoundTest.js
elm-0.19.3
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 1 module.
CompilerIssue1491PhantomTupleUnsoundTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/CompilerIssue1491PhantomTupleUnsoundTest.js
lamdera-1.5.0
failcompiled, but a compile error was expected --- compiler output --- Success! Compiled 1 module.
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CompilerIssue1491PhantomTupleUnsoundTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue1491PhantomTupleUnsoundTest exposing (..)
{-| A phantom type parameter `( m, m )` is accepted where `( OnePlus m, m )` is required.
<https://github.com/elm/compiler/issues/1491>
Elm 0.19.1 accepts `head nil`, although `Vect ( m, m ) a` and `Vect ( OnePlus m, m ) a` do not
unify (`m` would have to equal `OnePlus m`). It should report a type error.
The issue's own program used the library function `List.head` in `head`; this version reproduces
the same bug with a `case` on the list in its place.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-exp-app
-- COMPILE-ERROR: (m, m) does not unify with (OnePlus m, m)
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type OnePlus m
= OnePlus
type Vect m a
= Vect (List a)
nil : Vect ( m, m ) a
nil =
Vect []
head : Vect ( OnePlus m, m ) a -> Maybe a
head (Vect xs) =
case xs of
x :: _ ->
Just x
[] ->
Nothing
broken =
head nil
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_CompilerIssue1491PhantomTupleUnsoundTest, 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.