CompilerIssue2097ExtensibleUnitArgCrashTest
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#2097
An extensible-record alias applied to `()` must be rejected with an error report, not crash the compiler. <https://github.com/elm/compiler/issues/2097> Elm 0.19.1 crashes with "Used toAnnotation on a type that is not well-formed" (Type/Type.hs) and "thread blocked indefinitely in an MVar operation". `()` is not a record, so the program must be rejected with an ordinary error report. The issue's own program used the library function `List.map` in `f`; this version reproduces the same bug with a local `map` of the same type in its place.
Results
elm-0.19.1
failUnexpected pattern (CHECK-NOT): HasCallStack --- compiler output --- Dependencies ready! 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): HasCallStack --- compiler output --- Dependencies ready! 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): HasCallStack --- 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 CompilerIssue2097ExtensibleUnitArgCrashTest) 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 CompilerIssue2097ExtensibleUnitArgCrashTest) 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/CompilerIssue2097ExtensibleUnitArgCrashTest.elm
The 2nd argument to `w3_encode_Extensible` is not what I expect:
1| module CompilerIssue2097ExtensibleUnitArgCrashTest exposing (main, f)
^
This `encodeUnit` value is a:
() -> Lamdera.Wire3.Encoder
But `w3_encode_Extensible` needs the 2nd argument to be:
{ a | id : String } -> Lamdera.Wire3.Encoder
Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CompilerIssue2097ExtensibleUnitArgCrashTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue2097ExtensibleUnitArgCrashTest exposing (main, f)
{-| An extensible-record alias applied to `()` must be rejected with an error report, not crash
the compiler.
<https://github.com/elm/compiler/issues/2097>
Elm 0.19.1 crashes with "Used toAnnotation on a type that is not well-formed" (Type/Type.hs) and
"thread blocked indefinitely in an MVar operation". `()` is not a record, so the program must be
rejected with an ordinary error report.
The issue's own program used the library function `List.map` in `f`; this version reproduces the
same bug with a local `map` of the same type in its place.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-ty-con
-- COMPILE-ERROR: an ordinary error report, not a compiler crash
-- CHECK-NOT: HasCallStack
-- CHECK-NOT: not well-formed
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: bypassed the normal error reporting
import Html exposing (text)
main =
text "done"
type alias Extensible comparable a =
{ a | id : comparable }
type alias T =
Extensible String ()
map : (a -> b) -> List a -> List b
map g list =
case list of
[] ->
[]
x :: rest ->
g x :: map g rest
f : List T -> List String
f list =
map .id list
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_CompilerIssue2097ExtensibleUnitArgCrashTest, 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.