TypeMismatchTypeUnderAnExposingListTest
Tags:elm19-compile-errorelm-spec
Checks, in A Standard Definition of Elm?:rule s-valbind-varrule s-atexp-longcon
Not translated into Lean for the mechanisation of the book: see why.
A value annotated `Int` but defined as `Just 1` is rejected with a TYPE MISMATCH error. The module imports `Maybe` with `Maybe` in its exposing list, alongside two other imports with exposing lists, so the mismatched type is one the program has brought into scope unqualified.
Results
elm-0.19.1
passOutput
Compiling ...-- TYPE MISMATCH --------------- src/TypeMismatchTypeUnderAnExposingListTest.elm
Something is off with the body of the `x` definition:
21| x = Just 1
^^^^^^
This `Just` call produces:
Maybe number
But the type annotation on `x` says it should be:
Int
Hint: Use Maybe.withDefault to handle possible errors. Longer term, it is
usually better to write out the full `case` though!
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- TYPE MISMATCH --------------- src/TypeMismatchTypeUnderAnExposingListTest.elm
Something is off with the body of the `x` definition:
21| x = Just 1
^^^^^^
This `Just` call produces:
Maybe number
But the type annotation on `x` says it should be:
Int
Hint: Use Maybe.withDefault to handle possible errors. Longer term, it is
usually better to write out the full `case` though!
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- TYPE MISMATCH --------------- src/TypeMismatchTypeUnderAnExposingListTest.elm
Something is off with the body of the `x` definition:
21| x = Just 1
^^^^^^
This `Just` call produces:
Maybe number
But the type annotation on `x` says it should be:
Int
Hint: Use Maybe.withDefault to handle possible errors. Longer term, it is
usually better to write out the full `case` though!
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- TYPE MISMATCH --------------- src/TypeMismatchTypeUnderAnExposingListTest.elm
Something is off with the body of the `x` definition:
21| x = Just 1
^^^^^^
This `Just` call produces:
Maybe number
But the type annotation on `x` says it should be:
Int
Hint: Use Maybe.withDefault to handle possible errors. Longer term, it is
usually better to write out the full `case` though!
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/TypeMismatchTypeUnderAnExposingListTest] in its title.
Source
The -- CHECK: lines give the expected output.
module TypeMismatchTypeUnderAnExposingListTest exposing (..)
{-| A value annotated `Int` but defined as `Just 1` is rejected with a TYPE MISMATCH error.
The module imports `Maybe` with `Maybe` in its exposing list, alongside two other imports
with exposing lists, so the mismatched type is one the program has brought into scope
unqualified.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, s-valbind-var, s-atexp-longcon
-- COMPILE-ERROR: TYPE MISMATCH, type under an exposing list
-- CHECK: -- TYPE MISMATCH -
import Maybe exposing (Maybe)
import Tuple exposing (first, pair)
import List exposing (map)
x : Int
x = 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_TypeMismatchTypeUnderAnExposingListTest, in StandardElmMech/Certs/). An import of the program does not elaborate in the test basis (Stat.not_legal_of_imports). It holds for every derivation, with no hypothesis about principality.