CompilerIssue2176ExtensibleUnitAliasCrashTest
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#2176
A function between records typed with an extensible alias applied to `()` must be rejected with an error report, not crash the compiler. <https://github.com/elm/compiler/issues/2176> `ExtensibleT () dataT` is ill-formed (`()` is not a record). Elm 0.19.1 crashes with "Used toAnnotation on a type that is not well-formed" and "thread blocked indefinitely in an MVar operation" instead of reporting an error.
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 --- Dependencies ready! 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 CompilerIssue2176ExtensibleUnitAliasCrashTest) 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 CompilerIssue2176ExtensibleUnitAliasCrashTest) 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
Dependencies ready!
Detected problems in 1 module.
-- TYPE MISMATCH --------- src/CompilerIssue2176ExtensibleUnitAliasCrashTest.elm
The 1st argument to `w3_encode_ExtensibleT` is not what I expect:
1| module CompilerIssue2176ExtensibleUnitAliasCrashTest exposing (main, addExtension)
^
This `encodeUnit` value is a:
() -> Lamdera.Wire3.Encoder
But `w3_encode_ExtensibleT` needs the 1st argument to be:
{ extension | data : dataT } -> Lamdera.Wire3.Encoder
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CompilerIssue2176ExtensibleUnitAliasCrashTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CompilerIssue2176ExtensibleUnitAliasCrashTest exposing (main, addExtension)
{-| A function between records typed with an extensible alias applied to `()` must be rejected
with an error report, not crash the compiler.
<https://github.com/elm/compiler/issues/2176>
`ExtensibleT () dataT` is ill-formed (`()` is not a record). Elm 0.19.1 crashes with "Used
toAnnotation on a type that is not well-formed" and "thread blocked indefinitely in an MVar
operation" instead of reporting an error.
-}
-- TAGS: elm19-bug
-- TAGS: elm-spec, s-ty-con
-- COMPILE-ERROR: a type error, 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 ExtensibleT extension dataT =
{ extension | data : dataT }
type alias TWithOutExtension dataT =
ExtensibleT () dataT
type alias TWithSimpleExtension dataT =
ExtensibleT { simple : Int } dataT
addExtension : TWithOutExtension dataT -> TWithSimpleExtension dataT
addExtension { data } =
{ data = data, simple = 0 }
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_CompilerIssue2176ExtensibleUnitAliasCrashTest, 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.