Skip to content

"Pattern match has inaccessible right hand side" with TypeRep

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.

Trac metadata
Trac field Value
Version 8.5
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