Skip to content

"Defined but not used" for variable used in Template Haskell splice

I encountered this warning on valid code using Template Haskell ; I had to change "name" to "_name" to make it compile warning-free.

Test case:

{-# LANGUAGE FlexibleInstances, TemplateHaskell #-}
import Language.Haskell.TH

main :: IO ()
main = do
    let name = mkName "name"
    decl <- runQ [d| instance Show $(conT name) where show = undefined |]
    print decl

Warnings:

TestCase.hs:6:8: Warning: Defined but not used: `name'

I found ticket #3873 (closed), but I don't know if it represents the same bug.

Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information