[GHC] #14838: missing "incomplete-patterns" warning for TH-generated functions
GHC
ghc-devs at haskell.org
Wed Feb 21 21:28:07 UTC 2018
#14838: missing "incomplete-patterns" warning for TH-generated functions
-------------------------------------+-------------------------------------
Reporter: gelisam | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Template | Version: 8.2.2
Haskell |
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:
-------------------------------------+-------------------------------------
"incomplete-patterns" warnings are generated for TH-generated case
expressions, but not for TH-generated functions, so the behaviour is
inconsistent.
For example:
{{{#!hs
{-# LANGUAGE TemplateHaskell #-}
module Lib where
import Language.Haskell.TH
qIncompleteCase :: Q [Dec]
qIncompleteCase = [d|
incompleteCase :: Bool -> ()
incompleteCase b = case b of
True -> () |]
qIncompleteFunction :: Q [Dec]
qIncompleteFunction =[d|
incompleteFunction :: Bool -> ()
incompleteFunction True = () |]
}}}
{{{#!hs
{-# LANGUAGE TemplateHaskell #-}
module Bug where
import Lib
$qIncompleteCase
$qIncompleteFunction
incompleteCase' :: Bool -> ()
incompleteCase' b = case b of
True -> ()
incompleteFunction' :: Bool -> ()
incompleteFunction' True = ()
}}}
When compiling the above two files with `-Wall`, GHC 8.2.2 produces an
"incomplete-patterns" warning for `qIncompleteCase`, `incompleteCase'`,
and `incompleteFunction'`, but not for `qIncompleteFunction`. I would
prefer to get a warning for `qIncompleteFunction` as well.
My use case is the [https://hackage.haskell.org/package/surjective
surjective] package, in which I intentionally generate code which produces
warnings in order to warn the user about corresponding issues in their
code. I could generate
[https://github.com/gelisam/surjective/blob/master/src/Surjective.hs#L158-L162
better error messages] if GHC generated warnings for TH-generated
functions as well.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14838>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list