
#14765: Levity polymorphism panic -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Richard, this is a continuation of #12709. During desugaring we have {{{ f a b }}} Turns out that there's a levity-polymophism error in `(f a)`, so (bizarrely) `dsWhneNoErrs` returns `()`. Then the desugarer tries to apply that to `b`, and that fails because `()` isn't a function type. Hhe cure (for #12709) was ugly enough; now we find that it doesn't acutally work! Replacing an expression by `()` doesn't make sense -- the types are wrong. I can see two solutions (there may be others): * Instead of returning `()` return `undefined @ty` where `ty` is the needed type. But the whole `dsWhenNoErrs` machinery is very heavy; it calls `tryM` (which in turn allcoates fresh IO refes for errors etc) on every single application node. The cure is worse than the disease. So instead * We could define desugarer-only version of `mkCoreApp`, which doesn't blow up on levity-polymorphic args. (Maybe it builds an ordinary App, say.) It's a bit of code to duplicate but not much, and it's easy to understand. (Alternatively we could make `isUnliftedType` return False for a levity- poly type. That would be even simpler.) What do you think? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14765#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler