StandardA97MaybeNeverMissingJustTest
Tags:elm19-compile-errorelm-spec
Checks, in A Standard Definition of Elm?:restriction core-exhaustiveness
Not translated into Lean for the mechanisation of the book: see why.
A `case` on a `Maybe Never` must have a branch for `Just`. A Standard Definition of Elm?, ruling A97: inhabitants may be infinite, so `Maybe Never` has the inhabitant `Just (JustOneMore (JustOneMore ...))`, which `Nothing` does not cover, and the match is not exhaustive. <https://elm-test-suite.netlify.app/standard/restrictions/core-exhaustiveness> Elm 0.19.1 rejects the program with MISSING PATTERNS. Under finite inhabitants `Nothing` would be the only inhabitant, and the program would be accepted.
Results
elm-0.19.1
passOutput
Compiling ...-- MISSING PATTERNS --------------- src/StandardA97MaybeNeverMissingJustTest.elm
This `case` does not have branches for all possibilities:
24|> case m of
25|> Nothing ->
26|> 0
Missing possibilities include:
Just _
I would have to crash if I saw one of those. Add branches for them!
Hint: If you want to write the code for each branch later, use `Debug.todo` as a
placeholder. Read <https://elm-lang.org/0.19.1/missing-patterns> for more
guidance on this workflow.
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- MISSING PATTERNS --------------- src/StandardA97MaybeNeverMissingJustTest.elm
This `case` does not have branches for all possibilities:
24|> case m of
25|> Nothing ->
26|> 0
Missing possibilities include:
Just _
I would have to crash if I saw one of those. Add branches for them!
Hint: If you want to write the code for each branch later, use `Debug.todo` as a
placeholder. Read <https://elm-lang.org/0.19.2/missing-patterns> for more
guidance on this workflow.
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- MISSING PATTERNS --------------- src/StandardA97MaybeNeverMissingJustTest.elm
This `case` does not have branches for all possibilities:
24|> case m of
25|> Nothing ->
26|> 0
Missing possibilities include:
Just _
I would have to crash if I saw one of those. Add branches for them!
Hint: If you want to write the code for each branch later, use `Debug.todo` as a
placeholder. Read <https://elm-lang.org/0.19.3/missing-patterns> for more
guidance on this workflow.
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- MISSING PATTERNS --------------- src/StandardA97MaybeNeverMissingJustTest.elm
This `case` does not have branches for all possibilities:
24|> case m of
25|> Nothing ->
26|> 0
Missing possibilities include:
Just _
I would have to crash if I saw one of those. Add branches for them!
Hint: If you want to write the code for each branch later, use `Debug.todo` as a
placeholder. Read <https://elm-lang.org/0.19.3/missing-patterns> for more
guidance on this workflow.
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/StandardA97MaybeNeverMissingJustTest] in its title.
Source
The -- CHECK: lines give the expected output.
module StandardA97MaybeNeverMissingJustTest exposing (main)
{-| A `case` on a `Maybe Never` must have a branch for `Just`.
A Standard Definition of Elm?, ruling A97: inhabitants may be infinite, so `Maybe Never` has the
inhabitant `Just (JustOneMore (JustOneMore ...))`, which `Nothing` does not cover, and the match is
not exhaustive. <https://elm-test-suite.netlify.app/standard/restrictions/core-exhaustiveness>
Elm 0.19.1 rejects the program with MISSING PATTERNS. Under finite inhabitants `Nothing` would be
the only inhabitant, and the program would be accepted.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, core-exhaustiveness
-- COMPILE-ERROR: MISSING PATTERNS, Just on a Maybe Never
-- CHECK: -- MISSING PATTERNS -
import Html exposing (text)
count : Maybe Never -> Int
count m =
case m of
Nothing ->
0
main =
let
_ =
Debug.log "count Nothing" (count Nothing)
in
text "done"
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_StandardA97MaybeNeverMissingJustTest, in StandardElmMech/Certs/). The program breaks a further restriction (Chapter 9) in every derivation (Stat.not_legal_of_furtherFailB). It holds for every derivation, with no hypothesis about principality.