Elm Exactly
Results / elm /

StandardLetStrictTest

Tags:elm-spec

Checks, in A Standard Definition of Elm?:rule d-atexp-let

Translated into Lean for the mechanisation of the book: see its Lean translation.

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A `let` evaluates its declarations before its body, even a declaration whose value is not used:
`let _ = Debug.todo "x" in 1` has no value, so the program stops there.

A Standard Definition of Elm?, the Comment on rule r:d-atexp-let. The program logs `before`, then
stops at `Debug.todo`; `let strict` is never logged, and the program exits with status 1.
<https://elm-test-suite.netlify.app/standard/rules/d-atexp-let>

Results

elm-0.19.1

passran in 45 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardLetStrictTest.js:579
			throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
			^

Error: TODO in module `StandardLetStrictTest` on line 29

x
    at _Debug_crash (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardLetStrictTest.js:579:10)
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardLetStrictTest.js:335:3
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardLetStrictTest.js:4445:7
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardLetStrictTest.js:4447:4
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardLetStrictTest.js:4449:2
    at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardLetStrictTest.js:4450:122)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    at Object..js (node:internal/modules/cjs/loader:1913:10)
    at Module.load (node:internal/modules/cjs/loader:1505:32)
    at Function._load (node:internal/modules/cjs/loader:1309:12)

Node.js v22.23.5
before: ()

elm-0.19.2

passran in 77 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
before: ()
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardLetStrictTest.js:579
			throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
			^

Error: TODO in module `StandardLetStrictTest` on line 28

x
    at _Debug_crash (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardLetStrictTest.js:579:10)
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardLetStrictTest.js:335:3
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardLetStrictTest.js:4445:7
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardLetStrictTest.js:4447:4
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardLetStrictTest.js:4449:2
    at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardLetStrictTest.js:4450:122)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    at Object..js (node:internal/modules/cjs/loader:1913:10)
    at Module.load (node:internal/modules/cjs/loader:1505:32)
    at Function._load (node:internal/modules/cjs/loader:1309:12)

Node.js v22.23.5

elm-0.19.3

passran in 69 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
before: ()
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardLetStrictTest.js:579
			throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
			^

Error: TODO in module `StandardLetStrictTest` on line 29

x
    at _Debug_crash (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardLetStrictTest.js:579:10)
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardLetStrictTest.js:335:3
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardLetStrictTest.js:4445:7
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardLetStrictTest.js:4447:4
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardLetStrictTest.js:4449:2
    at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardLetStrictTest.js:4450:122)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    at Object..js (node:internal/modules/cjs/loader:1913:10)
    at Module.load (node:internal/modules/cjs/loader:1505:32)
    at Function._load (node:internal/modules/cjs/loader:1309:12)

Node.js v22.23.5

lamdera-1.5.0

passran in 58 ms
Output
before: ()
/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm/out/StandardLetStrictTest.js:611
			throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
			^

Error: TODO in module `StandardLetStrictTest` on line 29

x
    at _Debug_crash (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm/out/StandardLetStrictTest.js:611:10)
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm/out/StandardLetStrictTest.js:353:3
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm/out/StandardLetStrictTest.js:5515:7
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm/out/StandardLetStrictTest.js:5517:4
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm/out/StandardLetStrictTest.js:5519:2
    at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm/out/StandardLetStrictTest.js:5522:3)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    at Object..js (node:internal/modules/cjs/loader:1913:10)
    at Module.load (node:internal/modules/cjs/loader:1505:32)
    at Function._load (node:internal/modules/cjs/loader:1309:12)

Node.js v22.23.5

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StandardLetStrictTest exposing (main)
{-| A `let` evaluates its declarations before its body, even a declaration whose value is not used:
`let _ = Debug.todo "x" in 1` has no value, so the program stops there.
A Standard Definition of Elm?, the Comment on rule r:d-atexp-let. The program logs `before`, then
stops at `Debug.todo`; `let strict` is never logged, and the program exits with status 1.
<https://elm-test-suite.netlify.app/standard/rules/d-atexp-let>
-}
-- TAGS: elm-spec, d-atexp-let
-- EXIT: 1
-- CHECK: before: ()
-- CHECK-NOT: let strict:
import Html
main =
let
_ =
Debug.log "before" ()
_ =
Debug.log "let strict"
(let
_ =
Debug.todo "x"
in
1
)
in
Html.text "done"

Lean translation

This program is translated into Lean by the translator of the Lean mechanisation of A Standard Definition of Elm?: the program it is, its modules in the reduced syntax of Chapter 7 with every integer constant at Int or Float by number specialisation, and its CHECK lines as written (g_elm_StandardLetStrictTest, in StandardElmMech/Generated/Elm_StandardL.lean). Lean's evaluator runs the program by the rules of Chapters 7 and 9, and its checks become one generated theorem: some derivation of the program has a log that meets every check, or, for a test that stops at Debug.todo, the program has no meaning.

CheckExpected (CHECK)Lean evaluatorProved by
before()()no theorem: the program stops at Debug.todo, and its theorem says only that it has no meaning; the run of the examples compares what it logs first
let strict(no value)(no meaning)t_elm_StandardLetStrictTest
/-- tests/elm/src/StandardLetStrictTest.elm -/
def g_elm_StandardLetStrictTest : Program := {
  name := "StandardLetStrictTest", source := "tests/elm/src",
  exposing := (.items [.var "main"]), imports := [⟨"Html", "Html", none⟩],
  types := [],
  aliases := [],
  defs := [
    .fn "main" [] (letDefs [.pat pw (ap (qv "Debug" "log") [str "before", .atexp .unit]), .pat pw (ap (qv "Debug" "log") [str "let strict", .atexp (.paren (letDefs [.pat pw (ap (qv "Debug" "todo") [str "x"])] (.atexp (.scon (.intF 1)))))])] (ap (qv "Html" "text") [str "done"])) ],
  checks := [
    chk .check "before: ()" .data,
    chk .not_ "let strict:" .data ],
  meaning := false }

Reading the translation: v "x" is the variable x, c "K" the constructor K, i 42 the integer 42 at Int, .scon (.intF 2) the integer 2 at Float, and str "s" a string; ap f [a, b] applies f to a and then b, and bin "+" a b is a + b. lams, caseOf, ifte, listE, tup2 and recE build lambdas, case, if, lists, pairs and records by the book's derived forms; pv, pw and pcon are variable, wildcard and constructor patterns. defs are the program's top-level definitions and locals the other declarations of main's let, placed in a let around each check; ckk label value kind exp is one check. A name with $ (incF$Float) is a copy number specialisation made.

Static semantics (Chapters 4, 5 and 9): legal_elm_StandardLetStrictTest states that the program as written is legal, with no hypothesis: the proved inference W gives each module a principal derivation, which meets the syntactic restrictions and the further restrictions, with a type of main Chapter 9 allows. End to end: spec_elm_StandardLetStrictTest states that Lean computes the reduced program above from the source (derived forms, inference, the proved checker, number specialisation, type erasure), so the theorems about it do not trust the translator's elaboration ([elab]); the program has no meaning (it stops at Debug.todo).