Opened 19 months ago

Last modified 19 months ago

#14851 new bug

"Pattern match has inaccessible right hand side" with TypeRep

Reported by: goldfire Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.5
Keywords: PatternMatchWarnings, PatternSynonyms Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

When I say

{-# LANGUAGE PatternSynonyms, ViewPatterns #-}

module Bug where

import Type.Reflection

pattern X arg <- (checkFun -> arg)

checkFun :: TypeRep fun -> a
checkFun = undefined

f x = case (x, True) of
          (X _, _) -> 5
          _        -> 6

g x = case x of
          (X _) -> 5
          _     -> 6

I get

Bug.hs:13:11: warning: [-Woverlapping-patterns]
    Pattern match has inaccessible right hand side
    In a case alternative: (X _, _) -> ...
   |
13 |           (X _, _) -> 5
   |           ^^^^^^^^^^^^^

I'm troubled by two things:

  1. There's nothing inaccessible about my right-hand side.
  2. This happens only for f, not g. If there's no tuple, there's no problem.

Note that this problems requires TypeRep. Even another polykinded tycon (like Proxy) didn't trigger the problem.

Change History (1)

comment:1 Changed 19 months ago by RyanGlScott

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