
#13512: GHC incorrectly warns that a variable used in a type application is unused -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: Resolution: | TypeApplications Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Ah, you're right, it is in fact `rnValBindsRHS` that handles the renaming of function type signatures, not `rnValBindsLHS`. My mistake. But my point about there being a chicken-and-egg problem is still relevant, I believe. Here is the [http://git.haskell.org/ghc.git/blob/14457cf6a50f708eecece8f286f08687791d51f7... current definition] of `rnValBindsRHS`: {{{#!hs rnValBindsRHS :: HsSigCtxt -> HsValBindsLR GhcRn GhcPs -> RnM (HsValBinds GhcRn, DefUses) rnValBindsRHS ctxt (ValBindsIn mbinds sigs) = do { (sigs', sig_fvs) <- renameSigs ctxt sigs ; binds_w_dus <- mapBagM (rnLBind (mkSigTvFn sigs')) mbinds ; let !(anal_binds, anal_dus) = depAnalBinds binds_w_dus ; let patsyn_fvs = foldr (unionNameSet . psb_fvs) emptyNameSet $ getPatSynBinds anal_binds valbind'_dus = anal_dus `plusDU` usesOnly sig_fvs `plusDU` usesOnly patsyn_fvs ; return (ValBindsOut anal_binds sigs', valbind'_dus) } rnValBindsRHS _ b = pprPanic "rnValBindsRHS" (ppr b) }}} Notice that the call to `renameSigs` (in which all `Unused quantified type variable` warnings are emitted) occurs before the call to `rnLBind` (which would handle, e.g., `SomeProxy (proxy @k @a)`). Moreover, this has to be the case, since the result of `renameSigs` is fed into `rnLBind`. This makes me believe that the `Unused quantified type variable` analysis needs to be moved out of `bindLHsTyVarBndrs` and somewhere that can take into account the results of `rnValBindsRHS`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13512#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler