A name bound in a pattern in a matcher (e.g. case
) was the same as the name of a fun
declaration that contained the pattern.
fun foo x =
case x of
0 => 1
| foo => foo
(** ^^^ name bound in pattern inside a `case` matches name of a `fun` that contains the `case` *)
This is at best a possibly confusing case of shadowing.
This warning occurs in the following somewhat common scenario:
fun foo 0 y = y
| foo 1 y =
case y of
0 => 1
| 2 => 3
| _ => 4
| foo x y = x + y
(** ^^^ name bound in pattern inside a `case` matches name of a `fun` that contains the `case` *)
This looks like a fun
with many cases, one of which has an inner case
. However, most SML parsers (including Millet) attempt to parse the final foo x y
as part of the case
instead as part of the fun
. This leads to confusing errors, often 3001 and 3002.
Try one of the following:
- Put parentheses around the inner matcher (i.e.
case
,fn
, orhandle
). - Rename the binding to avoid shadowing.
fun foo 0 y = y
| foo 1 y =
(case y of
0 => 1
| 2 => 3
| _ => 4)
| foo x y = x + y