Elm Exactly
Results / elm /

ParseErrorCasePatternUnfinishedTest

Tags:elm19-bug-fixelm-spec

Checks, in A Standard Definition of Elm?:figure core-grammar-patterns

Not translated into Lean for the mechanisation of the book: see why.

elm-0.19.1 failelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A case pattern with an unclosed parenthesis, `(1 ->`, is reported as UNFINISHED PARENTHESES.

Fixed in Elm 0.19.2. Elm 0.19.1 reports this as UNEXPECTED SYMBOL, pointing at the `->`
rather than at the missing `)`.

Results

elm-0.19.1

fail
Missing pattern: -- UNFINISHED PARENTHESES -
--- compiler output ---
Compiling ...-- UNEXPECTED SYMBOL --------------- src/ParseErrorCasePatternUnfinishedTest.elm

I ran into the -> symbol unexpectedly in this pattern:

16|         (1 ->
               ^^
Only the :: symbol that works in patterns. It is useful if you are pattern
matching on lists, trying to get the first element off the front. Did you want
that instead?

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- UNFINISHED PARENTHESES ---------- src/ParseErrorCasePatternUnfinishedTest.elm

I was partway through parsing a pattern, but I got stuck here:

16|         (1 ->
               ^
I was expecting a closing parenthesis next, so try adding a ) to see if that
helps?

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- UNFINISHED PARENTHESES ---------- src/ParseErrorCasePatternUnfinishedTest.elm

I was partway through parsing a pattern, but I got stuck here:

16|         (1 ->
               ^
I was expecting a closing parenthesis next, so try adding a ) to see if that
helps?

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- UNFINISHED PARENTHESES ---------- src/ParseErrorCasePatternUnfinishedTest.elm

I was partway through parsing a pattern, but I got stuck here:

16|         (1 ->
               ^
I was expecting a closing parenthesis next, so try adding a ) to see if that
helps?

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm/ParseErrorCasePatternUnfinishedTest] in its title.

Source

The -- CHECK: lines give the expected output.

module ParseErrorCasePatternUnfinishedTest exposing (..)
{-| A case pattern with an unclosed parenthesis, `(1 ->`, is reported as UNFINISHED PARENTHESES.
Fixed in Elm 0.19.2. Elm 0.19.1 reports this as UNEXPECTED SYMBOL, pointing at the `->`
rather than at the missing `)`.
-}
-- TAGS: elm19-bug-fix
-- TAGS: elm-spec, fig:core-grammar-patterns
-- COMPILE-ERROR: UNFINISHED PARENTHESES
-- CHECK: -- UNFINISHED PARENTHESES -
f n =
case n of
(1 ->
0
_ ->
1

Lean translation

No reduced program for Lean's evaluator: the test expects a compile error, so it has no meaning to evaluate. Static semantics: expected to be rejected, and eco's parser rejects it too. See the Lean mechanisation for which tests are in Lean, and why.