Elm Exactly
Results / elm /

TooManyArgsAConstructorPatternWithTooManyArgumentsTest

Tags:elm19-compile-errorelm-spec

Checks, in A Standard Definition of Elm?:rule s-pat-con

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

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A constructor pattern with more arguments than the constructor takes is rejected with a TOO MANY ARGS error.

`Just` takes one argument, but the `case` in `f` matches `Just a b`.

Results

elm-0.19.1

pass
Output
Compiling ...-- TOO MANY ARGS - src/TooManyArgsAConstructorPatternWithTooManyArgumentsTest.elm

The `Just` variant needs 1 argument, but I see 2 instead:

16|         Just a b ->
            ^^^^^^^^
Which is the extra one? Maybe some parentheses are missing?

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- TOO MANY ARGS - src/TooManyArgsAConstructorPatternWithTooManyArgumentsTest.elm

The `Just` variant needs 1 argument, but I see 2 instead:

16|         Just a b ->
            ^^^^^^^^
Which is the extra one? Maybe some parentheses are missing?

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- TOO MANY ARGS - src/TooManyArgsAConstructorPatternWithTooManyArgumentsTest.elm

The `Just` variant needs 1 argument, but I see 2 instead:

16|         Just a b ->
            ^^^^^^^^
Which is the extra one? Maybe some parentheses are missing?

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- TOO MANY ARGS - src/TooManyArgsAConstructorPatternWithTooManyArgumentsTest.elm

The `Just` variant needs 1 argument, but I see 2 instead:

16|         Just a b ->
            ^^^^^^^^
Which is the extra one? Maybe some parentheses are missing?

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module TooManyArgsAConstructorPatternWithTooManyArgumentsTest exposing (..)
{-| A constructor pattern with more arguments than the constructor takes is rejected with a TOO MANY ARGS error.
`Just` takes one argument, but the `case` in `f` matches `Just a b`.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, s-pat-con
-- COMPILE-ERROR: TOO MANY ARGS, a constructor pattern with too many arguments
-- CHECK: -- TOO MANY ARGS -
f m =
case m of
Just a b ->
a
Nothing ->
0
testValue =
f (Just 1)

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_TooManyArgsAConstructorPatternWithTooManyArgumentsTest, in StandardElmMech/Certs/). A name is out of scope (or a constructor pattern has the wrong arity) in every derivation (Stat.not_legal_of_scopeFailB). It holds for every derivation, with no hypothesis about principality.