CompilerIssue1952ExtendIntCrashTest
Checks, in A Standard Definition of Elm?:rule s-ty-con
Not translated into Lean for the mechanisation of the book: see why.
Issue: elm/compiler#1952
Extending `Int` as if it were a record crashes the compiler while reporting the error.
<https://github.com/elm/compiler/issues/1952>
`Foo Int` extends the non-record `Int`. Elm 0.19.1 starts a TYPE MISMATCH report and then
crashes ("Used toErrorType on a type that is not well-formed"); it should report the error.Results
elm-0.19.1
failUnexpected pattern (CHECK-NOT): not well-formed
--- compiler output ---
Compiling ...-- TYPE MISMATCH ------------------- src/CompilerIssue1952ExtendIntCrashTest.elm
Something is off with the body of the `b` definition:
31| {}
^^
The body is a record of type:
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:541:21 in main:Type.Type
Detected problems in 1 module.
elm-0.19.2
failUnexpected pattern (CHECK-NOT): not well-formed
--- compiler output ---
Dependencies ready!
Compiling ...-- TYPE MISMATCH ------------------- src/CompilerIssue1952ExtendIntCrashTest.elm
Something is off with the body of the `b` definition:
31| {}
^^
The body is a record of type:
Detected problems in 1 module.
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:540:21 in elm-0.19.2-inplace-elm:Type.Type
elm-0.19.3
failUnexpected pattern (CHECK-NOT): not well-formed
--- compiler output ---
Dependencies ready!
Compiling ...-- TYPE MISMATCH ------------------- src/CompilerIssue1952ExtendIntCrashTest.elm
Something is off with the body of the `b` definition:
31| {}
^^
The body is a record of type:
elm: Used toErrorType on a type that is not well-formed
Type.Type.termToErrorType (line 507)
HasCallStack backtrace:
collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at compiler/src/Type/Type.hs:507:22 in elm-0.19.3-inplace-elm:Type.Type
Detected problems in 1 module.
lamdera-1.5.0
failUnexpected pattern (CHECK-NOT): not well-formed
--- compiler output ---
Dependencies ready!
Detected problems in 1 module.
-- TYPE MISMATCH ------------------- src/CompilerIssue1952ExtendIntCrashTest.elm
Something is off with the body of the `b` definition:
31| {}
^^
The body is a record of type:
lamdera: Crash {_module = Module "Type.Type", _name = Name "Type.Type.termToErrorType", _line = Line 1264, _message = "Used toErrorType on a type that is not well-formed"}
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CompilerIssue1952ExtendIntCrashTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue1952ExtendIntCrashTest exposing (..)
{-| Extending `Int` as if it were a record crashes the compiler while reporting the error.
<https://github.com/elm/compiler/issues/1952>
`Foo Int` extends the non-record `Int`. Elm 0.19.1 starts a TYPE MISMATCH report and then
crashes ("Used toErrorType on a type that is not well-formed"); it should report the error.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-ty-con
-- COMPILE-ERROR: extending a non-record
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: not well-formed
import Html
type alias Foo r =
{ r | foo : () }
type alias Bar =
Foo Int
b : Bar
b =
{}
main =
Html.text ""
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_CompilerIssue1952ExtendIntCrashTest, in StandardElmMech/Certs/). Some type expression of the program (an alias, a constructor's argument, an annotation, a port) elaborates in no derivation (Stat.not_legal_of_typesFailB). It holds for every derivation, with no hypothesis about principality.