Opened 6 years ago

Closed 4 years ago

Last modified 20 months ago

#9113 closed bug (duplicate)

Template Haskell should warn about non-exhaustive pattern matches

Reported by: tvh Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 7.8.2
Keywords: PatternMatchWarnings Cc: dimitris@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


When using Typed Template Haskell, There are no warings for non-exhaustive patterns inside the quote.

{-# LANGUAGE TemplateHaskell #-}

module Foo where

import Language.Haskell.TH.Lib

foo :: Maybe Int -> TExpQ Bool
foo x = [||case x of
            Nothing -> False||]

Instead the warnings appear where the code is spliced.

{-# LANGUAGE TemplateHaskell #-}

module Bar where

import Foo

x = $$(foo (Just 1))

Change History (3)

comment:1 Changed 6 years ago by simonpj

Cc: dimitris@… added

Good point. Currently pattern-match overlap warnings are produced as part of desugaring, which doesn't happen when type-checking the quotation.

However Dimitrios and some colleagues are thinking about how to integrate pattern-match overlap checking with the type checker, which would have the effect of solving this at the same time. I'll add him in cc.


comment:2 Changed 4 years ago by thomie

Resolution: duplicate
Status: newclosed

Because the existence of duplicate tickets makes doing a BugSweep of the bug tracker more cumbersome, I'm closing these tickets as duplicate. Don't worry, they're still listed on PatternMatchCheck, and will hopefully all be addressed by the work on #595 ("Overhaul GHC's overlapping/non-exhaustive pattern checking").

comment:3 Changed 20 months ago by simonpj

Keywords: PatternMatchWarnings added
Note: See TracTickets for help on using tickets.