StandardA84DuplicatePortNameTest
Checks, in A Standard Definition of Elm?:rule p-stat-main-programrule p-stat-modulerestriction modules-program
Not translated into Lean for the mechanisation of the book: see why.
Two ports of one program may not have the same name. A Standard Definition of Elm?, ruling A84: the name of every port of a program is distinct from those of its other ports (and of the platform's managers); a program that breaks this does not elaborate. <https://elm-test-suite.netlify.app/standard/restrictions/modules-program> <https://elm-test-suite.netlify.app/standard/rules/p-stat-module> This module and `StandardA84PortsHelper` both declare a port `send`. Elm 0.19.1 compiles the program; it stops when it starts, as the two ports collide at run time.
Results
elm-0.19.1
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 2 modules.
StandardA84DuplicatePortNameTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm/out/StandardA84DuplicatePortNameTest.js
elm-0.19.2
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 2 modules.
StandardA84DuplicatePortNameTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm/out/StandardA84DuplicatePortNameTest.js
elm-0.19.3
failcompiled, but a compile error was expected
--- compiler output ---
Success! Compiled 2 modules.
StandardA84DuplicatePortNameTest ───> /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm/out/StandardA84DuplicatePortNameTest.js
lamdera-1.5.0
failcompiled, but a compile error was expected --- compiler output --- Success! Compiled 2 modules.
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/StandardA84DuplicatePortNameTest] in its title.
Source
The -- CHECK: lines give the expected output.
port module StandardA84DuplicatePortNameTest exposing (main)
{-| Two ports of one program may not have the same name.
A Standard Definition of Elm?, ruling A84: the name of every port of a program is distinct from
those of its other ports (and of the platform's managers); a program that breaks this does not
elaborate. <https://elm-test-suite.netlify.app/standard/restrictions/modules-program> <https://elm-test-suite.netlify.app/standard/rules/p-stat-module>
This module and `StandardA84PortsHelper` both declare a port `send`. Elm 0.19.1 compiles the program;
it stops when it starts, as the two ports collide at run time.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, p-stat-main-program, p-stat-module, modules-program
-- COMPILE-ERROR: two ports named send in one program
-- CHECK: {{-- [A-Z ]+ -}}
import StandardA84PortsHelper
port send : String -> Cmd msg
main : Program () () ()
main =
Platform.worker
{ init = \_ -> ( (), Cmd.batch [ send "one", StandardA84PortsHelper.send "two" ] )
, update = \_ model -> ( model, 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_StandardA84DuplicatePortNameTest, in StandardElmMech/Certs/). The program breaks a syntactic restriction, which the kernel checks on its syntax tree; no type inference is involved (Stat.not_legal_of_syn): res:modules-program. It holds for every derivation, with no hypothesis about principality.