CaseCharEscapedDuplicateTest
Checks, in A Standard Definition of Elm?:restriction core-irredundancy
Not translated into Lean for the mechanisation of the book: see why.
A `case` on Char with two patterns for the same character written differently ('a' and
'\u{0061}'): the second can never match, so it is a redundant pattern.
Elm 0.19.1 treats the two spellings as different patterns, so it accepts this program and the
second branch is dead code. The correct behaviour is a REDUNDANT PATTERN error. Fixed in Elm 0.19.2.Results
elm-0.19.1
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 1 module.
CaseCharEscapedDuplicateTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/CaseCharEscapedDuplicateTest.js
elm-0.19.2
passOutput
Compiling ...-- REDUNDANT PATTERN ---------------------- src/CaseCharEscapedDuplicateTest.elm
The 2nd pattern is redundant:
20| case c of
21| 'a' -> 1
22|> '\u{0061}' -> 2
23| 'b' -> 3
24| _ -> 4
Any value with this shape will be handled by a previous pattern, so it should be
removed.
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- REDUNDANT PATTERN ---------------------- src/CaseCharEscapedDuplicateTest.elm
The 2nd pattern is redundant:
20| case c of
21| 'a' -> 1
22|> '\u{0061}' -> 2
23| 'b' -> 3
24| _ -> 4
Any value with this shape will be handled by a previous pattern, so it should be
removed.
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- REDUNDANT PATTERN ---------------------- src/CaseCharEscapedDuplicateTest.elm
The 2nd pattern is redundant:
20| case c of
21| 'a' -> 1
22|> '\u{0061}' -> 2
23| 'b' -> 3
24| _ -> 4
Any value with this shape will be handled by a previous pattern, so it should be
removed.
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CaseCharEscapedDuplicateTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CaseCharEscapedDuplicateTest exposing (main)
{-| A `case` on Char with two patterns for the same character written differently ('a' and
'\u{0061}'): the second can never match, so it is a redundant pattern.
Elm 0.19.1 treats the two spellings as different patterns, so it accepts this program and the
second branch is dead code. The correct behaviour is a REDUNDANT PATTERN error. Fixed in Elm 0.19.2.
-}
-- TAGS: elm19-bug-fix
-- TAGS: elm-spec, core-irredundancy
-- COMPILE-ERROR: REDUNDANT PATTERN, the same Char written two ways
-- CHECK: -- REDUNDANT PATTERN -
import Html exposing (text)
classify c =
case c of
'a' -> 1
'\u{0061}' -> 2
'b' -> 3
_ -> 4
main =
text (Debug.toString (classify 'a'))
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_CaseCharEscapedDuplicateTest, 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.