CompilerIssue1550RecordExtensionDuplicateFieldTest
Checks, in A Standard Definition of Elm?:rule s-ty-conrule s-ty-openrecord
Not translated into Lean for the mechanisation of the book: see why.
Issue: elm/compiler#1550
Extending a record type with a field it already has is accepted, and the field's type is replaced.
<https://github.com/elm/compiler/issues/1550>
`A B` is `{ { x : String } | x : Int }`, a record with two `x` fields. Elm 0.19.1 accepts it
(and `{ x = 1 }` as a value of it); a duplicate field should be a compile error, as it is
everywhere else.Results
elm-0.19.1
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 1 module.
CompilerIssue1550RecordExtensionDuplicateFieldTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/CompilerIssue1550RecordExtensionDuplicateFieldTest.js
elm-0.19.2
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 1 module.
CompilerIssue1550RecordExtensionDuplicateFieldTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/CompilerIssue1550RecordExtensionDuplicateFieldTest.js
elm-0.19.3
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 1 module.
CompilerIssue1550RecordExtensionDuplicateFieldTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/CompilerIssue1550RecordExtensionDuplicateFieldTest.js
lamdera-1.5.0
failcompiled, but a compile error was expected --- compiler output --- Success! Compiled 1 module.
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CompilerIssue1550RecordExtensionDuplicateFieldTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue1550RecordExtensionDuplicateFieldTest exposing (..)
{-| Extending a record type with a field it already has is accepted, and the field's type is replaced.
<https://github.com/elm/compiler/issues/1550>
`A B` is `{ { x : String } | x : Int }`, a record with two `x` fields. Elm 0.19.1 accepts it
(and `{ x = 1 }` as a value of it); a duplicate field should be a compile error, as it is
everywhere else.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-ty-con, s-ty-openrecord
-- COMPILE-ERROR: duplicate field x through record extension
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type alias A a =
{ a | x : Int }
type alias B =
{ x : String }
test : A B
test =
{ x = 1 }
main =
Html.text ""
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_CompilerIssue1550RecordExtensionDuplicateFieldTest, in StandardElmMech/Certs/). Some type expression of the program (an alias, a constructor's argument, an annotation, a port) elaborates in no derivation (Stat.not_legal_of_typesFailB). It holds for every derivation, with no hypothesis about principality.