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

Weird assertion in unification #22

Open
osa1 opened this issue Aug 30, 2024 · 0 comments
Open

Weird assertion in unification #22

osa1 opened this issue Aug 30, 2024 · 0 comments

Comments

@osa1
Copy link
Contributor

osa1 commented Aug 30, 2024

In the type checker we have this assertion when setting link of an unification variable:

Ty::Var(var) => {
assert!(var.link().is_none());
var.prune_level(max_level);
}

I don't remember why I thought that assertion was necessary. Consider unifying types of a value and a pattern:

let x = Option.Some(123)        # Option[I32]
match x:
    Option.Some(i): ...
    Option.None: ...

Here the unifications we do:

  • I32 ~ _0: argument of instantiated type of Option.Some with type of 123.
  • _1 ~ Option[_0]: type of Option.Some(123) with type of x.

In the second step, we link _1 -> Option[_0], and prune the level of of Option[_0] to _1s level. That prune opeartion fails because _0 is linked to I32 in the previous unification step.

For now I'll comment-out the assertion.

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