Each name in a pattern binds a new variable, so one name can't appear twice. Auk patterns
don't test equality by repeating a name: use a when guard for that.
Wrong#
fn same(p: (int, int)): bool = match p {
(a, a) => true
_ => false
}Fixed#
fn same(p: (int, int)): bool = match p {
(a, b) when a == b => true
_ => false
}Common causes#
- Expecting a repeated name to mean "these are equal" (as in Prolog or Erlang).
- A copy-paste typo in a tuple or list pattern.