CoreIssue955KillProcessTwiceTest
Checks, in A Standard Definition of Elm?:rule p-proc-spawnrule p-proc-killrule e-task-andthen-succeed
Translated into Lean for the mechanisation of the book: see its Lean translation.
Issue: elm/core#955
Killing a process that has already finished, a second time, throws a JavaScript error. <https://github.com/elm/core/issues/955> Elm 0.19.1 crashes with `TypeError: Cannot read properties of null (reading '#039;)`. Killing a dead process should be a no-op, and the task should complete.
Results
elm-0.19.1
failran in 65 msexit code 1, expected 0
--- 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-core/out/CoreIssue955KillProcessTwiceTest.js:894
if (task.$ === 2 && task.c)
^
TypeError: Cannot read properties of null (reading '#039;)
at Object.b (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:894:12)
at _Scheduler_step (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:959:22)
at _Scheduler_enqueue (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:933:3)
at _Scheduler_rawSend (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:879:2)
at _Platform_dispatchEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2106:3)
at _Platform_enqueueEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2092:3)
at _Platform_initialize (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1893:2)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1861:9
at Object.init (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.js:20:33)
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-core/out/CoreIssue955KillProcessTwiceTest.run.js:2:99)
Node.js v22.23.5
elm-0.19.2
failran in 74 msexit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:894
if (task.$ === 2 && task.c)
^
TypeError: Cannot read properties of null (reading '#039;)
at Object.b (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:894:12)
at _Scheduler_step (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:959:22)
at _Scheduler_enqueue (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:933:3)
at _Scheduler_rawSend (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:879:2)
at _Platform_dispatchEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2106:3)
at _Platform_enqueueEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2092:3)
at _Platform_initialize (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1893:2)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1861:9
at Object.init (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.js:20:33)
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-core/out/CoreIssue955KillProcessTwiceTest.run.js:2:99)
Node.js v22.23.5
elm-0.19.3
failran in 75 msexit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1749
if (task.$ === 2 && task.c)
^
TypeError: Cannot read properties of null (reading '#039;)
at Object.b (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1749:12)
at _Scheduler_step (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1814:22)
at _Scheduler_enqueue (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1788:3)
at _Scheduler_rawSend (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1734:2)
at _Platform_dispatchEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2106:3)
at _Platform_enqueueEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2092:3)
at _Platform_initialize (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1893:2)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1861:9
at Object.init (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.js:20:33)
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-core/out/CoreIssue955KillProcessTwiceTest.run.js:2:99)
Node.js v22.23.5
lamdera-1.5.0
failran in 52 msexit code 1, expected 0
--- output ---
/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1796
if (task.$ === 2 && task.c)
^
TypeError: Cannot read properties of null (reading '#039;)
at Object.b (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1796:12)
at _Scheduler_step (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1877:22)
at _Scheduler_enqueue (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1851:3)
at _Scheduler_rawSend (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1781:2)
at _Platform_dispatchEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2438:3)
at _Platform_enqueueEffects (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2424:3)
at _Platform_initialize (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2003:2)
at init (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:1926:10)
at Object.init (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.js:2795:13)
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-core/out/CoreIssue955KillProcessTwiceTest.run.js:2:99)
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-core/CoreIssue955KillProcessTwiceTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CoreIssue955KillProcessTwiceTest exposing (main)
{-| Killing a process that has already finished, a second time, throws a JavaScript error.
<https://github.com/elm/core/issues/955>
Elm 0.19.1 crashes with `TypeError: Cannot read properties of null (reading '#039;)`. Killing a
dead process should be a no-op, and the task should complete.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, p-proc-spawn, p-proc-kill, e-task-andthen-succeed
-- CHECK: killed twice: ()
import Process
import Task exposing (Task)
killProcessTwice : Task Never ()
killProcessTwice =
Process.spawn (Task.succeed ())
|> Task.andThen
(\pid ->
Process.kill pid
|> Task.andThen (\_ -> Process.kill pid)
)
main : Program () () ()
main =
Platform.worker
{ init = \_ -> ( (), Task.perform identity killProcessTwice )
, update = \msg model -> ( Debug.log "killed twice" msg |> always model, Cmd.none )
, subscriptions = \_ -> Sub.none
}
Lean translation
This worker program is translated into Lean by the translator of the Lean mechanisation of A Standard Definition of Elm? (g_elm_core_CoreIssue955KillProcessTwiceTest, in StandardElmMech/Generated/Worker01.lean). Lean evaluates its modules by the rules of Chapter 7, starts it by r:p-init with no flags (null, A72), and runs it by the transitions of Chapter 9 under a host that sends nothing. Its checks become one generated theorem: some execution the book allows, under that host, has a log (the modules', then the start's, then each step's) that meets every check. The theorem trusts the parser and the translator's elaboration ([parse] [elab]), the test basis ([harness]) and the parameters of the basis ([params]), and is proved by the kernel.
| Check | Expected (CHECK) | Lean evaluator | Proved by |
|---|---|---|---|
killed twice | () | () | t_elm_core_CoreIssue955KillProcessTwiceTest |
/-- tests/elm-core/src/CoreIssue955KillProcessTwiceTest.elm -/
def g_elm_core_CoreIssue955KillProcessTwiceTest : Program := {
name := "CoreIssue955KillProcessTwiceTest", source := "tests/elm-core/src",
exposing := (.items [.var "main"]), imports := [⟨"Process", "Process", none⟩, ⟨"Task", "Task", some (.items [.tycon "Task"])⟩],
types := [],
aliases := [],
defs := [
.fn "killProcessTwice" [] (bin "|>" (ap (qv "Process" "spawn") [.atexp (.paren (ap (qv "Task" "succeed") [.atexp .unit]))]) (ap (qv "Task" "andThen") [.atexp (.paren (lams [pv "pid"] (bin "|>" (ap (qv "Process" "kill") [v "pid"]) (ap (qv "Task" "andThen") [.atexp (.paren (lams [pw] (ap (qv "Process" "kill") [v "pid"])))]))))])),
.fn "main" [] (ap (qv "Platform" "worker") [recE [("init", lams [pw] (tup2 (.atexp .unit) (ap (qv "Task" "perform") [v "identity", v "killProcessTwice"]))), ("update", lams [pv "msg", pv "model"] (tup2 (bin "|>" (ap (qv "Debug" "log") [str "killed twice", v "msg"]) (ap (v "always") [v "model"])) (qv "Cmd" "none"))), ("subscriptions", lams [pw] (qv "Sub" "none"))]]) ],
checks := [
chk .check "killed twice: ()" .data ] }
/-- The worker test of CoreIssue955KillProcessTwiceTest. -/
def w_elm_core_CoreIssue955KillProcessTwiceTest : Prog.WorkerTest := {
prog := g_elm_core_CoreIssue955KillProcessTwiceTest,
flagsType := .unit,
flags := .null,
host := .none,
checks := [] }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_core_CoreIssue955KillProcessTwiceTest 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_core_CoreIssue955KillProcessTwiceTest 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]); mean_elm_core_CoreIssue955KillProcessTwiceTest states that the program has a meaning by r:p-program, with both premises, and ident_elm_core_CoreIssue955KillProcessTwiceTest that its specialisation is unique and is the reduced program above, both with no hypothesis about principality.