TypeMismatchTwoFlexibleRecordsTest
Tags:elm19-compile-errorelm-spec
Checks, in A Standard Definition of Elm?:rule s-atpat-recordrule s-exp-app
Not translated into Lean for the mechanisation of the book: see why.
A record argument whose `name` field is used both as a number and as a `String` is rejected with a TYPE MISMATCH. In `k c`, `c.name + 1` needs `name` to be a number, while passing `c` to `h`, which computes `a.name ++ "s"`, needs it to be a `String`.
Results
elm-0.19.1
passOutput
Compiling ...-- TYPE MISMATCH -------------------- src/TypeMismatchTwoFlexibleRecordsTest.elm
The 1st argument to `h` is not what I expect:
20| h c
^
This `c` value is a:
{ a | name : number }
But `h` needs the 1st argument to be:
{ a | name : String }
Hint: Try using String.fromInt to convert it to a string?
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- TYPE MISMATCH -------------------- src/TypeMismatchTwoFlexibleRecordsTest.elm
The 1st argument to `h` is not what I expect:
20| h c
^
This `c` value is a:
{ a | name : number }
But `h` needs the 1st argument to be:
{ a | name : String }
Hint: Try using String.fromInt to convert it to a string?
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- TYPE MISMATCH -------------------- src/TypeMismatchTwoFlexibleRecordsTest.elm
The 1st argument to `h` is not what I expect:
20| h c
^
This `c` value is a:
{ a | name : number }
But `h` needs the 1st argument to be:
{ a | name : String }
Hint: Try using String.fromInt to convert it to a string?
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- TYPE MISMATCH -------------------- src/TypeMismatchTwoFlexibleRecordsTest.elm
The 1st argument to `h` is not what I expect:
20| h c
^
This `c` value is a:
{ a | name : number }
But `h` needs the 1st argument to be:
{ a | name : String }
Hint: Try using String.fromInt to convert it to a string?
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/TypeMismatchTwoFlexibleRecordsTest] in its title.
Source
The -- CHECK: lines give the expected output.
module TypeMismatchTwoFlexibleRecordsTest exposing (..)
{-| A record argument whose `name` field is used both as a number and as a `String` is rejected with a TYPE MISMATCH.
In `k c`, `c.name + 1` needs `name` to be a number, while passing `c` to `h`, which computes `a.name ++ "s"`, needs it to be a `String`.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, s-atpat-record, s-exp-app
-- COMPILE-ERROR: TYPE MISMATCH, two flexible records
-- CHECK: -- TYPE MISMATCH -
h a = a.name ++ "s"
k c =
let
z = c.name + 1
in
h c
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_TypeMismatchTwoFlexibleRecordsTest, in StandardElmMech/Certs/). The proved inference W fails on a module of the program, and W fails only where no derivation exists (plan step 11) (Stat.not_legal_of_wRefutes). It holds for every derivation, with no hypothesis about principality.