BadMainRecursiveUnannotatedMainTest
Tags:elm19-compile-errorelm-spec
Checks, in A Standard Definition of Elm?:restriction program-mainrule p-stat-main-programrule p-stat-main-view
Not translated into Lean for the mechanisation of the book: see why.
An unannotated `main` that is mutually recursive with another function is rejected with a BAD MAIN error. `main x` calls `f x`, and `f x` calls `main x`; neither has a type annotation.
Results
elm-0.19.1
passOutput
Compiling ...-- BAD MAIN ------------------------ src/BadMainRecursiveUnannotatedMainTest.elm
A `main` definition cannot be defined in terms of itself.
14| main x = f x
^^^^
It should be a boring value with no recursion. But instead it is involved in
this cycle of definitions:
┌─────┐
│ main
│ ↓
│ f
└─────┘
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- BAD MAIN ------------------------ src/BadMainRecursiveUnannotatedMainTest.elm
A `main` definition cannot be defined in terms of itself.
14| main x = f x
^^^^
It should be a boring value with no recursion. But instead it is involved in
this cycle of definitions:
┌─────┐
│ main
│ ↓
│ f
└─────┘
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- BAD MAIN ------------------------ src/BadMainRecursiveUnannotatedMainTest.elm
A `main` definition cannot be defined in terms of itself.
14| main x = f x
^^^^
It should be a boring value with no recursion. But instead it is involved in
this cycle of definitions:
┌─────┐
│ main
│ ↓
│ f
└─────┘
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- BAD MAIN ------------------------ src/BadMainRecursiveUnannotatedMainTest.elm
A `main` definition cannot be defined in terms of itself.
14| main x = f x
^^^^
It should be a boring value with no recursion. But instead it is involved in
this cycle of definitions:
┌─────┐
│ main
│ ↓
│ f
└─────┘
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/BadMainRecursiveUnannotatedMainTest] in its title.
Source
The -- CHECK: lines give the expected output.
module BadMainRecursiveUnannotatedMainTest exposing (..)
{-| An unannotated `main` that is mutually recursive with another function is rejected with a BAD MAIN error.
`main x` calls `f x`, and `f x` calls `main x`; neither has a type annotation.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, program-main, p-stat-main-program, p-stat-main-view
-- COMPILE-ERROR: BAD MAIN, recursive unannotated main
-- CHECK: -- BAD MAIN -
main x = f x
f x = main x
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_BadMainRecursiveUnannotatedMainTest, in StandardElmMech/Certs/). Every derivation gives main a type Chapter 9 does not allow (Stat.not_legal_of_mainFailB). It holds for every derivation, with no hypothesis about principality.