Elm Exactly
Results / elm /

NameClashTwoArgumentsOfOneNameTest

Tags:elm19-compile-errorelm-spec

Checks, in A Standard Definition of Elm?:restriction core-binding-site-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 function whose two arguments share one name, `pick a a`, is rejected with a NAME CLASH error.

Results

elm-0.19.1

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

The `pick` function has multiple `a` arguments.

12| pick a a =
           ^                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

elm-0.19.2

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

The `pick` function has multiple `a` arguments.

11| pick a a =
         ^ ^
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/NameClashTwoArgumentsOfOneNameTest.elm

The `pick` function has multiple `a` arguments.

11| pick a a =
         ^ ^
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/NameClashTwoArgumentsOfOneNameTest.elm

The `pick` function has multiple `a` arguments.

11| pick a 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/NameClashTwoArgumentsOfOneNameTest] in its title.

Source

The -- CHECK: lines give the expected output.

module NameClashTwoArgumentsOfOneNameTest exposing (..)
{-| A function whose two arguments share one name, `pick a a`, is rejected with a NAME CLASH error.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, core-binding-site-distinct
-- COMPILE-ERROR: NAME CLASH, two arguments of one name
-- CHECK: -- NAME CLASH -
pick a a =
a
testValue =
pick 1 2

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_NameClashTwoArgumentsOfOneNameTest, 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_modsyn): res:core-binding-site-distinct. It holds for every derivation, with no hypothesis about principality.