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

Fixed two type matching bugs #203

Merged
merged 1 commit into from
Aug 11, 2015
Merged

Fixed two type matching bugs #203

merged 1 commit into from
Aug 11, 2015

Conversation

EliasC
Copy link
Contributor

@EliasC EliasC commented Aug 10, 2015

This commit fixes two bugs related to matching types:

passive class Foo<a>
  def foo(x : Bar<a>) : a
    x.bar() -- #1 Can't match 'b' with 'a'

passive class Bar<b>
  f : b
  def init(f : b) : void
    this.f = f
  def bar() : b
    this.f

class Main {
  def main() : void {
    let
      x = new Foo<int>
      y = new Bar<int>(42)
    in{
      print x.foo(y) -- #2 Type 'Bar<int>' does not match expected type 'Bar<t>'
    }
  }
}

The first bug prevented matching two type variables unless they had the
same name. The second one prevented correctly matching against a
parametric type whose parameter was itself the type parameter of the
enclosing class.

This commit fixes two bugs related to matching types:

```
passive class Foo<a>
  def foo(x : Bar<a>) : a
    x.bar() -- #1 Can't match 'b' with 'a'

passive class Bar<b>
  f : b
  def init(f : b) : void
    this.f = f
  def bar() : b
    this.f

class Main {
  def main() : void {
    let
      x = new Foo<int>
      y = new Bar<int>(42)
    in{
      print x.foo(y) -- #2 Type 'Bar<int>' does not match expected type 'Bar<t>'
    }
  }
}
```

The first bug prevented matching two type variables unless they had the
same name. The second one prevented correctly matching against a
parametric type whose parameter was itself the type parameter of the
enclosing class.
kikofernandez pushed a commit that referenced this pull request Aug 11, 2015
@kikofernandez kikofernandez merged commit dee9e47 into parapluu:master Aug 11, 2015
@kikofernandez kikofernandez deleted the fix/typematching-bugs branch August 11, 2015 10:38
@albertnetymk
Copy link
Contributor

class Main
    def main() : void
    let app = \(f : a -> b, g:b->c, x : a) -> {
          let y = f(x) in g(x)
        }
    in
      ()

Not sure if it's intended, the above snippets typechecks after the merge.

@EliasC
Copy link
Contributor Author

EliasC commented Aug 11, 2015

@albertnetymk You are right! You showed me this program before, but I forgot to test with it now. Good catch! See PR #205 for a fix.

albertnetymk added a commit that referenced this pull request Aug 13, 2015
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

Successfully merging this pull request may close these issues.

3 participants