Skip to content

Wrong location for type error in pattern synonym

Summary

Some type error in a pattern synonym gets reported at the wrong location.

Steps to reproduce

{-# LANGUAGE PatternSynonyms, ViewPatterns #-}

pattern P :: Bool -> (Int, ())
pattern P p <- (p, _)
p.hs:4:20: error:
    • Couldn't match expected type ‘Bool’ with actual type ‘Int’
    • In the declaration for pattern synonym ‘P’
  |
4 | pattern P p <- (p, _)
  |                    ^

I've reproduced this with GHC 8.4, 8.6, 8.8, 8.10

Expected behavior

The problem is with p:

  |
4 | pattern P p <- (p, _)
  |                 ^
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information