Elm Exactly
Results / elm /

StandardA96NumberFlagsTest

Tags:elm19-compile-errorelm-spec

Checks, in A Standard Definition of Elm?:rule p-stat-main-program

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 `main` whose flags type is a `number` variable is refused.

`init = \n -> ( n + 1, Cmd.none )` and nothing else fixes the type of the flags, so in the
principal type of `main` they are a type variable of class `number`. A Standard Definition of Elm?,
ruling A96: rule p-stat-main-program checks that the flags type is a port type in the principal
scheme of `main`, before the default of `number` to Float, and a type variable is not a port type.
<https://elm-test-suite.netlify.app/standard/rules/p-stat-main-program>

Elm 0.19.1 refuses the program with BAD FLAGS: "type variables like `number` cannot be given as
flags".

Results

elm-0.19.1

pass
Output
Compiling ...-- BAD FLAGS -------------------------------- src/StandardA96NumberFlagsTest.elm

Your `main` program wants an unspecified type from JavaScript.

22| main =
    ^^^^
But type variables like `number` cannot be given as flags. I need to know
exactly what type of data I am getting, so I can guarantee that unexpected data
cannot sneak in and crash the Elm program.

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- BAD FLAGS -------------------------------- src/StandardA96NumberFlagsTest.elm

Your `main` program wants an unspecified type from JavaScript.

22| main =
    ^^^^
But type variables like `number` cannot be given as flags. I need to know
exactly what type of data I am getting, so I can guarantee that unexpected data
cannot sneak in and crash the Elm program.

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- BAD FLAGS -------------------------------- src/StandardA96NumberFlagsTest.elm

Your `main` program wants an unspecified type from JavaScript.

22| main =
    ^^^^
But type variables like `number` cannot be given as flags. I need to know
exactly what type of data I am getting, so I can guarantee that unexpected data
cannot sneak in and crash the Elm program.

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- BAD FLAGS -------------------------------- src/StandardA96NumberFlagsTest.elm

Your `main` program wants an unspecified type from JavaScript.

22| main =
    ^^^^
But type variables like `number` cannot be given as flags. I need to know
exactly what type of data I am getting, so I can guarantee that unexpected data
cannot sneak in and crash the Elm program.

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StandardA96NumberFlagsTest exposing (main)
{-| A `main` whose flags type is a `number` variable is refused.
`init = \n -> ( n + 1, Cmd.none )` and nothing else fixes the type of the flags, so in the
principal type of `main` they are a type variable of class `number`. A Standard Definition of Elm?,
ruling A96: rule p-stat-main-program checks that the flags type is a port type in the principal
scheme of `main`, before the default of `number` to Float, and a type variable is not a port type.
<https://elm-test-suite.netlify.app/standard/rules/p-stat-main-program>
Elm 0.19.1 refuses the program with BAD FLAGS: "type variables like `number` cannot be given as
flags".
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, p-stat-main-program
-- COMPILE-ERROR: BAD FLAGS, flags of class number
-- CHECK: -- BAD FLAGS -
main =
Platform.worker
{ init = \n -> ( n + 1, Cmd.none )
, update = \_ m -> ( m, Cmd.none )
, subscriptions = \_ -> Sub.none
}

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_StandardA96NumberFlagsTest, in StandardElmMech/Certs/). The proved inference W gives main a type variable as its flags type; every principal derivation keeps it, and no port type is a variable (Stat.not_legal_of_wMainVar_test). It holds for every derivation, with no hypothesis about principality.