Elm Exactly
Results / elm /

TopLevelPortAndValueSameNameTest

Tags:elm-spec

Checks, in A Standard Definition of Elm?:restriction modules-values-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 port and a top-level value may not have the same name.

A Standard Definition of Elm?, restriction modules-values-distinct: no top-level declaration may
bind the same variable twice by its value declarations and port declarations together.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-values-distinct>

Results

elm-0.19.1

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

This file has multiple `send` declarations. One here:

22| send _ =
    ^^^^
And another one here:

18| port send : String -> Cmd msg
         ^^^^
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/TopLevelPortAndValueSameNameTest.elm

This file has multiple `send` declarations. One here:

18| port send : String -> Cmd msg
         ^^^^
And another one here:

22| send _ =
    ^^^^
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/TopLevelPortAndValueSameNameTest.elm

This file has multiple `send` declarations. One here:

18| port send : String -> Cmd msg
         ^^^^
And another one here:

22| send _ =
    ^^^^
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/TopLevelPortAndValueSameNameTest.elm

This file has multiple `send` declarations. One here:

18| port send : String -> Cmd msg
         ^^^^
And another one here:

22| send _ =
    ^^^^
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/TopLevelPortAndValueSameNameTest] in its title.

Source

The -- CHECK: lines give the expected output.

port module TopLevelPortAndValueSameNameTest exposing (main)
{-| A port and a top-level value may not have the same name.
A Standard Definition of Elm?, restriction modules-values-distinct: no top-level declaration may
bind the same variable twice by its value declarations and port declarations together.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-values-distinct>
-}
-- TAGS: elm-spec, modules-values-distinct
-- COMPILE-ERROR: a port and a value with one name
-- CHECK: {{-- [A-Z ]+ -}}
import Html
port send : String -> Cmd msg
send : String -> Cmd msg
send _ =
Cmd.none
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_TopLevelPortAndValueSameNameTest, 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-values-distinct. It holds for every derivation, with no hypothesis about principality.