Elm Exactly
Results / elm /

TopLevelRecordAliasConstructorClashTest

Tags:elm-spec

Checks, in A Standard Definition of Elm?:restriction modules-constructors-distinct

Not translated into Lean for the mechanisation of the book: see why.

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A record alias declares a constructor, which may not clash with a custom type's.

A Standard Definition of Elm?, restriction modules-constructors-distinct: a record alias `P` also
declares a constructor `P`, so it counts against a constructor `P` of a custom type.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-constructors-distinct>

Results

elm-0.19.1

pass
Output
Compiling ...-- NAME CLASH ------------------ src/TopLevelRecordAliasConstructorClashTest.elm

This file defines multiple `P` type constructors. One here:

19|     = P Int
          ^
And another one here:

22| type alias P =
               ^
How can I know which one you want? Rename one of them!

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- NAME CLASH ------------------ src/TopLevelRecordAliasConstructorClashTest.elm

This file defines multiple `P` type constructors. One here:

19|     = P Int
          ^
And another one here:

22| type alias P =
               ^
How can I know which one you want? Rename one of them!

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- NAME CLASH ------------------ src/TopLevelRecordAliasConstructorClashTest.elm

This file defines multiple `P` type constructors. One here:

19|     = P Int
          ^
And another one here:

22| type alias P =
               ^
How can I know which one you want? Rename one of them!

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- NAME CLASH ------------------ src/TopLevelRecordAliasConstructorClashTest.elm

This file defines multiple `P` type constructors. One here:

19|     = P Int
          ^
And another one here:

22| type alias P =
               ^
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/TopLevelRecordAliasConstructorClashTest] in its title.

Source

The -- CHECK: lines give the expected output.

module TopLevelRecordAliasConstructorClashTest exposing (main)
{-| A record alias declares a constructor, which may not clash with a custom type's.
A Standard Definition of Elm?, restriction modules-constructors-distinct: a record alias `P` also
declares a constructor `P`, so it counts against a constructor `P` of a custom type.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-constructors-distinct>
-}
-- TAGS: elm-spec, modules-constructors-distinct
-- COMPILE-ERROR: a record alias constructor and a custom-type constructor with one name
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type Shape
= P Int
type alias P =
{ x : Int, y : 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_TopLevelRecordAliasConstructorClashTest, 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-constructors-distinct. It holds for every derivation, with no hypothesis about principality.