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

Corrected regression of #203 #205

Merged
merged 1 commit into from
Aug 13, 2015
Merged

Corrected regression of #203 #205

merged 1 commit into from
Aug 13, 2015

Conversation

EliasC
Copy link
Contributor

@EliasC EliasC commented Aug 11, 2015

This PR fixes the bug introduced by #203 (found by @albertnetymk). The following program now (correctly) does not compile:

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

@albertnetymk
Copy link
Contributor

Why is replaceTypeVars in exactMatch needed? In addition, the name exactMatch seems odd, for it's doing exact match not doing exact match.

@EliasC
Copy link
Contributor Author

EliasC commented Aug 12, 2015

replaceTypeVars in exactMatch is probably a residual from before we replaced all type variables before matching the types. I think it could be removed. Why is exactMatch an odd name if it's doing exact match?

@albertnetymk
Copy link
Contributor

Sorry, forgot the not there. Updated.

@EliasC
Copy link
Contributor Author

EliasC commented Aug 12, 2015

Is assertMatch better?

@albertnetymk
Copy link
Contributor

Yes, I feel so.

This commit fixes the regression that made the following
program (incorrectly) compile:
```
class Main
  def main() : void
    let app = \(f:a->b, g:b->c, x : a) ->
                 let y = f(x) in g(x)
    in
      ()
```
It also includes some changes suggested by @albertnetymk.

== Message of the fixed commit ==

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.
@EliasC
Copy link
Contributor Author

EliasC commented Aug 12, 2015

Done and done!

@EliasC
Copy link
Contributor Author

EliasC commented Aug 12, 2015

I also renamed some functions to avoid possible name confusion

@albertnetymk
Copy link
Contributor

I think it could be merged, if there's no objections from others.

albertnetymk added a commit that referenced this pull request Aug 13, 2015
@albertnetymk albertnetymk merged commit d6e99b2 into parapluu:master Aug 13, 2015
@EliasC EliasC deleted the fix/typematching-bug-bug branch August 14, 2015 06:25
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.

2 participants