
#11438: Code does not compile without ScopedTypeVariables -------------------------------------+------------------------------------- Reporter: wereHamster | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.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 goldfire): This is not a bug, but we could do much better in suggesting `ScopedTypeVariables`. The reason that the change makes a difference is that you refer to the type variable `sublayout` from within a method definition in your instance. You need `ScopedTypeVariables` to bring the instance's type variables into scope. An easy way of suggesting `ScopedTypeVariables` just came to mind: pretend the extension is always on. When looking up a type variable, if the extension is off but the variable would be in scope otherwise, suggest the extension, while returning a lookup failure (because the variable really isn't in scope!). Getting caught on `ScopedTypeVariables` is a fairly common occurrence in my experience, so I think it's worth putting in a bit of effort to do better here. (Even better would be to look for type variables in a signature that's missing a `forall` to suggest adding the `forall`, but that can be a separate task.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11438#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler