Elm Exactly
Results / elm /

ShadowingShadowingInLambdaTest

Tags:elm19-compile-errorelm-spec

Checks, in A Standard Definition of Elm?:restriction core-no-shadowing

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 lambda argument with the same name as an argument of the enclosing function is rejected with a SHADOWING error.

In `test y = \y -> y`, the lambda's `y` shadows the function's `y`.

Results

elm-0.19.1

pass
Output
Compiling ...-- SHADOWING ---------------------------- src/ShadowingShadowingInLambdaTest.elm

The name `y` is first defined here:

14| test y =
         ^
But then it is defined AGAIN over here:

15|     \y ->
         ^
Think of a more helpful name for one of them and you should be all set!

Note: Linters advise against shadowing, so Elm makes “best practices” the
default. Read <https://elm-lang.org/0.19.1/shadowing> for more details on this
choice.

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- SHADOWING ---------------------------- src/ShadowingShadowingInLambdaTest.elm

The name `y` is first defined here:

14| test y =
         ^
But then it is defined AGAIN over here:

15|     \y ->
         ^
Think of a more helpful name for one of them and you should be all set!

Note: Linters advise against shadowing, so Elm makes “best practices” the
default. Read <https://elm-lang.org/0.19.2/shadowing> for more details on this
choice.

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- SHADOWING ---------------------------- src/ShadowingShadowingInLambdaTest.elm

The name `y` is first defined here:

14| test y =
         ^
But then it is defined AGAIN over here:

15|     \y ->
         ^
Think of a more helpful name for one of them and you should be all set!

Note: Linters advise against shadowing, so Elm makes “best practices” the
default. Read <https://elm-lang.org/0.19.3/shadowing> for more details on this
choice.

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- SHADOWING ---------------------------- src/ShadowingShadowingInLambdaTest.elm

The name `y` is first defined here:

14| test y =
         ^
But then it is defined AGAIN over here:

15|     \y ->
         ^
Think of a more helpful name for one of them and you should be all set!

Note: Linters advise against shadowing, so Elm makes “best practices” the
default. Read <https://elm-lang.org/0.19.3/shadowing> for more details on this
choice.

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm/ShadowingShadowingInLambdaTest] in its title.

Source

The -- CHECK: lines give the expected output.

module ShadowingShadowingInLambdaTest exposing (..)
{-| A lambda argument with the same name as an argument of the enclosing function is rejected with a SHADOWING error.
In `test y = \y -> y`, the lambda's `y` shadows the function's `y`.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, core-no-shadowing
-- COMPILE-ERROR: SHADOWING, shadowing in lambda
-- CHECK: -- SHADOWING -
test y =
\y ->
y

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_ShadowingShadowingInLambdaTest, 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-no-shadowing. It holds for every derivation, with no hypothesis about principality.