
#14318: TH shadowing bind statement triggers -Wunused-matches -------------------------------------+------------------------------------- Reporter: lyxia | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.1 Resolution: | Keywords: 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: | -------------------------------------+------------------------------------- Description changed by lyxia: Old description:
{{{ $(newName "x" >>= \x -> newName "f" >>= \f -> lamE [varP f, varP x] (doE [ bindS (varP x) (listE [varE f `appE` varE x]) , noBindS (varE x)]) ) }}}
generates the following expression:
{{{ \f x -> do x <- f x x }}}
and `-Wunused-matches` complains that `x` is not used, while both bound occurrences are in fact used.
New description: {{{ {-# LANGUAGE TemplateHaskell #-} module Test where import Language.Haskell.TH m :: (a -> [b]) -> a -> [b] m = $(newName "x" >>= \x -> newName "f" >>= \f -> lamE [varP f, varP x] (doE [ bindS (varP x) (listE [varE f `appE` varE x]) , noBindS (varE x)]) ) }}} The splice generates the following expression: {{{ \f x -> do x <- [f x] x }}} and `-Wunused-matches` complains that `x` is not used, while both bound occurrences are in fact used (the two uses have different types so that's quite certain). -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14318#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler