CompilerIssue2064ExtendStringNotEnoughBytesTest
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#2064
Extending `String` as if it were a record inside a custom type crashes the compiler. <https://github.com/elm/compiler/issues/2064> `Named String`, a constructor argument of `Something`, extends the non-record `String`. Elm 0.19.1 crashes; it should report an error.
Results
elm-0.19.1
failUnexpected pattern (CHECK-NOT): CallStack --- compiler output --- Compiling ...elm: Used toAnnotation on a type that is not well-formed CallStack (from HasCallStack): error, called at compiler/src/Type/Type.hs:413:21 in main:Type.Type -- ERROR ----------------------------------------------------------------------- I ran into something that bypassed the normal error reporting process! I extracted whatever information I could from the internal error: > thread blocked indefinitely in an MVar operation These errors are usually pretty confusing, so start by asking around on one of forums listed at https://elm-lang.org/community to see if anyone can get you unstuck quickly. -- REQUEST --------------------------------------------------------------------- If you are feeling up to it, please try to get your code down to the smallest version that still triggers this message. Ideally in a single Main.elm and elm.json file. From there open a NEW issue at https://github.com/elm/compiler/issues with your reduced example pasted in directly. (Not a link to a repo or gist!) Do not worry about if someone else saw something similar. More examples is better! This kind of error is usually tied up in larger architectural choices that are hard to change, so even when we have a couple good examples, it can take some time to resolve in a solid way.elm: thread blocked indefinitely in an MVar operation
elm-0.19.2
failUnexpected pattern (CHECK-NOT): CallStack --- compiler output --- Compiling ...elm: Used toAnnotation on a type that is not well-formed CallStack (from HasCallStack): error, called at compiler/src/Type/Type.hs:412:21 in elm-0.19.2-inplace-elm:Type.Type -- ERROR ----------------------------------------------------------------------- I ran into something that bypassed the normal error reporting process! I extracted whatever information I could from the internal error: > thread blocked indefinitely in an MVar operation These errors are usually pretty confusing, so start by asking around on one of forums listed at https://elm-lang.org/community to see if anyone can get you unstuck quickly. -- REQUEST --------------------------------------------------------------------- If you are feeling up to it, please try to get your code down to the smallest version that still triggers this message. Ideally in a single Main.elm and elm.json file. From there open a NEW issue at https://github.com/elm/compiler/issues with your reduced example pasted in directly. (Not a link to a repo or gist!) Do not worry about if someone else saw something similar. More examples is better! This kind of error is usually tied up in larger architectural choices that are hard to change, so even when we have a couple good examples, it can take some time to resolve in a solid way.elm: thread blocked indefinitely in an MVar operation
elm-0.19.3
failUnexpected pattern (CHECK-NOT): CallStack --- compiler output --- Compiling ... -- ERROR ----------------------------------------------------------------------- I ran into something that bypassed the normal error reporting process! I extracted whatever information I could from the internal error: > Used toAnnotation on a type that is not well-formed > > Type.Type.termToCanType (line 374) (in module CompilerIssue2064ExtendStringNotEnoughBytesTest) These errors are usually pretty confusing, so start by asking around on one of forums listed at https://elm-lang.org/community to see if anyone can get you unstuck quickly. -- REQUEST --------------------------------------------------------------------- If you are feeling up to it, please try to get your code down to the smallest version that still triggers this message. Ideally in a single Main.elm and elm.json file. From there open a NEW issue at https://github.com/elm/compiler/issues with your reduced example pasted in directly. (Not a link to a repo or gist!) Do not worry about if someone else saw something similar. More examples is better! This kind of error is usually tied up in larger architectural choices that are hard to change, so even when we have a couple good examples, it can take some time to resolve in a solid way.elm: Used toAnnotation on a type that is not well-formed Type.Type.termToCanType (line 374) (in module CompilerIssue2064ExtendStringNotEnoughBytesTest) 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 builder/src/Reporting.hs:445:45 in elm-0.19.3-inplace-elm:Reporting
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- TYPE MISMATCH ------- src/CompilerIssue2064ExtendStringNotEnoughBytesTest.elm
This function cannot handle the argument sent through the (|>) pipe:
1| module CompilerIssue2064ExtendStringNotEnoughBytesTest exposing (..)
^
The argument is:
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/CompilerIssue2064ExtendStringNotEnoughBytesTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue2064ExtendStringNotEnoughBytesTest exposing (..)
{-| Extending `String` as if it were a record inside a custom type crashes the compiler.
<https://github.com/elm/compiler/issues/2064>
`Named String`, a constructor argument of `Something`, extends the non-record `String`. Elm 0.19.1
crashes; it should report an error.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-ty-con
-- COMPILE-ERROR: extending a non-record
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: CallStack
import Html
type alias Named a =
{ a | name : String }
type Something
= Something (Named String)
type alias Model =
{ something : Something }
init =
{ something = Something }
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_CompilerIssue2064ExtendStringNotEnoughBytesTest, 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.