CompilerIssue2200ConstrainedExtensibleErrorCrashTest
Checks, in A Standard Definition of Elm?:rule s-ty-openrecord
Not translated into Lean for the mechanisation of the book: see why.
Issue: elm/compiler#2200
A type error for an extensible record whose row variable is the constrained `number` must be
reported completely, not crash the compiler.
<https://github.com/elm/compiler/issues/2200>
`{ number | field : () }` with the body `()` is a type error. Elm 0.19.1 starts printing the TYPE
MISMATCH report and then crashes with "Used toErrorType on a type that is not well-formed"
(Type/Type.hs:541). The report must be complete.Results
elm-0.19.1
failUnexpected pattern (CHECK-NOT): HasCallStack
--- compiler output ---
Dependencies ready!
Compiling ...-- TYPE MISMATCH -- src/CompilerIssue2200ConstrainedExtensibleErrorCrashTest.elm
Something is off with the body of the `number` definition:
30| ()
^^
The body is a unit value:
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:541:21 in main:Type.Type
elm-0.19.2
failUnexpected pattern (CHECK-NOT): HasCallStack
--- compiler output ---
Dependencies ready!
Compiling ...-- TYPE MISMATCH -- src/CompilerIssue2200ConstrainedExtensibleErrorCrashTest.elm
Something is off with the body of the `number` definition:
30| ()
^^
The body is a unit value:
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): HasCallStack
--- compiler output ---
Dependencies ready!
Compiling ...-- TYPE MISMATCH -- src/CompilerIssue2200ConstrainedExtensibleErrorCrashTest.elm
Something is off with the body of the `number` definition:
30| ()
^^
The body is a unit value:
Detected problems in 1 module.
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
lamdera-1.5.0
failUnexpected pattern (CHECK-NOT): not well-formed
--- compiler output ---
Dependencies ready!
Detected problems in 1 module.
-- TYPE MISMATCH -- src/CompilerIssue2200ConstrainedExtensibleErrorCrashTest.elm
Something is off with the body of the `number` definition:
30| ()
^^
The body is a unit value:
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/CompilerIssue2200ConstrainedExtensibleErrorCrashTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue2200ConstrainedExtensibleErrorCrashTest exposing (main)
{-| A type error for an extensible record whose row variable is the constrained `number` must be
reported completely, not crash the compiler.
<https://github.com/elm/compiler/issues/2200>
`{ number | field : () }` with the body `()` is a type error. Elm 0.19.1 starts printing the TYPE
MISMATCH report and then crashes with "Used toErrorType on a type that is not well-formed"
(Type/Type.hs:541). The report must be complete.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-ty-openrecord
-- COMPILE-ERROR: TYPE MISMATCH, printed completely
-- CHECK-NOT: HasCallStack
-- CHECK: -- TYPE MISMATCH -
-- CHECK-NOT: not well-formed
import Html exposing (text)
main =
text "done"
number : { number | field : () }
number =
()
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_CompilerIssue2200ConstrainedExtensibleErrorCrashTest, 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.