Elm Exactly
Results / elm /

NamingErrorAnUnknownVariableTest

Tags:elm19-compile-errorelm-spec

Checks, in A Standard Definition of Elm?:rule s-atexp-longvar

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 reference to a variable that is defined nowhere, `undefinedName`, is rejected with a NAMING ERROR.

Results

elm-0.19.1

pass
Output
Compiling ...-- NAMING ERROR ----------------------- src/NamingErrorAnUnknownVariableTest.elm

I cannot find a `undefinedName` variable:

13|     undefinedName + 1
        ^^^^^^^^^^^^^
These names seem close though:

    Cmd.none
    isInfinite
    negate
    Basics.negate

Hint: Read <https://elm-lang.org/0.19.1/imports> to see how `import`
declarations work in Elm.

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- NAMING ERROR ----------------------- src/NamingErrorAnUnknownVariableTest.elm

I cannot find a `undefinedName` variable:

13|     undefinedName + 1
        ^^^^^^^^^^^^^
These names seem close though:

    Cmd.none
    isInfinite
    negate
    Basics.negate

Hint: Read <https://elm-lang.org/0.19.2/imports> to see how `import`
declarations work in Elm.

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- NAMING ERROR ----------------------- src/NamingErrorAnUnknownVariableTest.elm

I cannot find a `undefinedName` variable:

13|     undefinedName + 1
        ^^^^^^^^^^^^^
These names seem close though:

    Cmd.none
    negate
    isInfinite
    Sub.none

Hint: Read <https://elm-lang.org/0.19.3/imports> to see how `import`
declarations work in Elm.

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- NAMING ERROR ----------------------- src/NamingErrorAnUnknownVariableTest.elm

I cannot find a `undefinedName` variable:

13|     undefinedName + 1
        ^^^^^^^^^^^^^
These names seem close though:

    Cmd.none
    negate
    isInfinite
    Sub.none

Hint: Read <https://elm-lang.org/0.19.3/imports> to see how `import`
declarations work in Elm.

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module NamingErrorAnUnknownVariableTest exposing (..)
{-| A reference to a variable that is defined nowhere, `undefinedName`, is rejected with a NAMING ERROR.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, s-atexp-longvar
-- COMPILE-ERROR: NAMING ERROR, an unknown variable
-- CHECK: -- NAMING ERROR -
testValue =
undefinedName + 1

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_NamingErrorAnUnknownVariableTest, in StandardElmMech/Certs/). A name is out of scope (or a constructor pattern has the wrong arity) in every derivation (Stat.not_legal_of_scopeFailB). It holds for every derivation, with no hypothesis about principality.