Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError in TypeResolver.deducePatType when distinct variables have the same name #197

Open
julianhyde opened this issue Jul 10, 2023 · 0 comments

Comments

@julianhyde
Copy link
Collaborator

The function

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant