
#13458: Panic with unsafeCoerce and -dcore-lint -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.1 checker) | Keywords: Resolution: | 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 goldfire): I'm on it. Indeed, I believe I've fixed this, but need to rebuild to be sure. The problem is the checks from #9122 that try to make sure we're not `unsafeCoerce`ing between types with incompatible representations. But when we look to see about the representations involved here, the types don't have representations, so GHC falls over. What's annoying is that the user-written program is safe in this regard. It's the coercion optimizer that rewrites an `unsafeCoerce` from a lifted type to a lifted type (`Any -> Any` to `a -> b`) to two `unsafeCoerce`s involving `a` and `b` separately. Thus, an alternate fix would be to have the coercion optimizer look for precisely this scenario and avoid pushing the unsafe coercion through the `->`. I haven't done this for two reasons: 1. Failing the checks from #9122 (which I've never fully agreed with) is a sometimes-unavoidable consequence of a sketchy `unsafeCoerce`. The workaround if you're in this scenario is not to use `-dcore-lint`. The original program is pretty sketchy here, and so requiring that user to avoid `-dcore-lint` may be reasonable. 2. It's quite annoying (and potentially computationally expensive) to do this check in the coercion optimizer. The check is necessary only when the user is willfully misbehaving, and the better citizens shouldn't have to pay for it every time. Regardless, GHC shouldn't panic. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13458#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler