10

I'm getting a warning from GHC when I compile:

Warning: This binding for 'pats' shadows an existing binding in the definition of 'match_ignore_ancs'

Here's the function:

match_ignore_ancs (TextPat _ c) (Text t) = c t
match_ignore_ancs (TextPat _ _) (Element _ _ _) = False
match_ignore_ancs (ElemPat _ _ _) (Text t) = False
match_ignore_ancs (ElemPat _ c pats) (Element t avs xs) =
   c t avs && match_pats pats xs

Any idea what this means and how I can fix it?

Cheers.

Alistair
  • 8,066
  • 14
  • 39
  • 43
  • What would happen if you rename both `pats` in `match_ignore_ancs` to something else, e. g. `pats1` ? – YasirA May 25 '10 at 08:05
  • An obvious next question is: "How does one find out where that existing binding comes from?". That is, in the current module, or which imported module? – wstomv Oct 18 '21 at 12:58

1 Answers1

11

It means that you have a symbol pats defined somewhere else in your program or imported from some library module, and it's visible in the same scope as match_ignore_ancs, so when you name a parameter pats, it hides (i.e. "shadows") that existing symbol.

Just rename the pats parameter to something that doesn't have a collision.

Ganesh Sittampalam
  • 28,821
  • 4
  • 79
  • 98