
#16322: "deriving newtype instance" generates an infinite loop -------------------------------------+------------------------------------- Reporter: paf31 | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Replying to [comment:5 paf31]:
I understand that only the last argument is coerced, but even so, that would require an instance for `C (X String a) b`, which in this specific case instantiates to `C (X String Int) Int`, and the functional dependency should (I think) force this to fail via `X String Int ~ Int`. No?
If you had written `instance C (X String a) b => C (X String a) (X String b)`, then that would be the case. But you didn't—you specifically wrote `instance C a b => C (X String a) (X String b)`, which has no functional dependency issues.
But I still think it shouldn't loop at runtime.
For the same reasons I explained in comment:4, the code that gets generated is `c = coerce c`, where the two occurrences of `c` have the same type, i.e., an infinite loop. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16322#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler