TopLevelTypeAndAliasSameNameTest
Tags:elm-spec
Checks, in A Standard Definition of Elm?:restriction modules-types-distinct
Not translated into Lean for the mechanisation of the book: see why.
A custom type and a type alias may not have the same name. A Standard Definition of Elm?, restriction modules-types-distinct: custom types and aliases share one name space, and no module declares a type name twice. <https://elm-test-suite.netlify.app/standard/restrictions/modules-types-distinct>
Results
elm-0.19.1
passOutput
Compiling ...-- NAME CLASH ------------------------- src/TopLevelTypeAndAliasSameNameTest.elm
This file defines multiple `A` types. One here:
17| type A
^
And another one here:
21| type alias A =
^
How can I know which one you want? Rename one of them!
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- NAME CLASH ------------------------- src/TopLevelTypeAndAliasSameNameTest.elm
This file defines multiple `A` types. One here:
21| type alias A =
^
And another one here:
17| type A
^
How can I know which one you want? Rename one of them!
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- NAME CLASH ------------------------- src/TopLevelTypeAndAliasSameNameTest.elm
This file defines multiple `A` types. One here:
21| type alias A =
^
And another one here:
17| type A
^
How can I know which one you want? Rename one of them!
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- NAME CLASH ------------------------- src/TopLevelTypeAndAliasSameNameTest.elm
This file defines multiple `A` types. One here:
21| type alias A =
^
And another one here:
17| type A
^
How can I know which one you want? Rename one of them!
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/TopLevelTypeAndAliasSameNameTest] in its title.
Source
The -- CHECK: lines give the expected output.
module TopLevelTypeAndAliasSameNameTest exposing (main)
{-| A custom type and a type alias may not have the same name.
A Standard Definition of Elm?, restriction modules-types-distinct: custom types and aliases share
one name space, and no module declares a type name twice. <https://elm-test-suite.netlify.app/standard/restrictions/modules-types-distinct>
-}
-- TAGS: elm-spec, modules-types-distinct
-- COMPILE-ERROR: a custom type and an alias with one name
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type A
= A Int
type alias A =
Int
main =
Html.text "done"
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_TopLevelTypeAndAliasSameNameTest, in StandardElmMech/Certs/). The program breaks a syntactic restriction, which the kernel checks on its syntax tree; no type inference is involved (Stat.not_legal_of_syn): res:modules-types-distinct. It holds for every derivation, with no hypothesis about principality.