fun foo (f, n) =
let
fun factorial 0 = 1
| factorial n = f (n * factorial (n - 1))
in
factorial n
end;
throws the following exception:
Exception in thread "main" java.lang.AssertionError
at net.hydromatic.morel.compile.TypeResolver.deducePatType(TypeResolver.java:1117)
at net.hydromatic.morel.compile.TypeResolver.deduceMatchListType(TypeResolver.java:675)
at net.hydromatic.morel.compile.TypeResolver.deduceType(TypeResolver.java:303)
The similar function
fun foo (f, n) =
let
fun factorial 0 = 1
| factorial k = f (k * factorial (k - 1))
in
factorial n
end;
has no error; the only difference is that the shadowing variable n is renamed to k. Perhaps the problem is caused by duplicate variable names.
The function
throws the following exception:
The similar function
has no error; the only difference is that the shadowing variable
n
is renamed tok
. Perhaps the problem is caused by duplicate variable names.