TooFewArgsAConstructorPatternWithTooFewArgumentsTest
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.
A constructor pattern with fewer arguments than the constructor takes is rejected with a TOO FEW ARGS error. `Pair` takes two `Int`s, but the argument pattern of `first` is `(Pair a)`.
Results
elm-0.19.1
passOutput
Compiling ...-- TOO FEW ARGS --- src/TooFewArgsAConstructorPatternWithTooFewArgumentsTest.elm
The `Pair` variant needs 2 arguments, but I see 1 instead:
18| first (Pair a) =
^^^^^^
What is missing? Are some parentheses misplaced?
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- TOO FEW ARGS --- src/TooFewArgsAConstructorPatternWithTooFewArgumentsTest.elm
The `Pair` variant needs 2 arguments, but I see 1 instead:
18| first (Pair a) =
^^^^^^
What is missing? Are some parentheses misplaced?
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- TOO FEW ARGS --- src/TooFewArgsAConstructorPatternWithTooFewArgumentsTest.elm
The `Pair` variant needs 2 arguments, but I see 1 instead:
18| first (Pair a) =
^^^^^^
What is missing? Are some parentheses misplaced?
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- TOO FEW ARGS --- src/TooFewArgsAConstructorPatternWithTooFewArgumentsTest.elm
The `Pair` variant needs 2 arguments, but I see 1 instead:
18| first (Pair a) =
^^^^^^
What is missing? Are some parentheses misplaced?
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/TooFewArgsAConstructorPatternWithTooFewArgumentsTest] in its title.
Source
The -- CHECK: lines give the expected output.
module TooFewArgsAConstructorPatternWithTooFewArgumentsTest exposing (..)
{-| A constructor pattern with fewer arguments than the constructor takes is rejected with a TOO FEW ARGS error.
`Pair` takes two `Int`s, but the argument pattern of `first` is `(Pair a)`.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, s-pat-con
-- COMPILE-ERROR: TOO FEW ARGS, a constructor pattern with too few arguments
-- CHECK: -- TOO FEW ARGS -
type Pair
= Pair Int Int
first (Pair a) =
a
testValue =
first (Pair 1 2)
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_TooFewArgsAConstructorPatternWithTooFewArgumentsTest, 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.