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

Refactor typechecker to hide type substitution #361

Merged
merged 1 commit into from
Apr 7, 2016
Merged

Refactor typechecker to hide type substitution #361

merged 1 commit into from
Apr 7, 2016

Conversation

EliasC
Copy link
Contributor

@EliasC EliasC commented Apr 6, 2016

This commit refactors the way type substitution is handled so that it is
completely encapsulated in the lookup rules of the environment. As an
example, take the following class

passive class Foo<t>
  f : t

class Main
  def main() : void {
    let x = new Foo<int>;
    x.f = 42;
  }

In order to ensure that the assignment on the last line is valid, we
need to build a set of bindings that maps t to int, so that the
field f : t looks like f : int when we do the lookup. Instead of
cluttering the typechecker with this sort of thing, this translation is
now done implicitly on field lookup.

Since it's refactoring, I have included no new tests (or documentation).

This commit refactors the way type substitution is handled so that it is
completely encapsulated in the lookup rules of the environment. As an
example, take the following class
```
passive class Foo<t>
  f : t

class Main
  def main() : void {
    let x = new Foo<int>;
    x.f = 42;
  }
```

In order to ensure that the assignment on the last line is valid, we
need to build a set of bindings that maps `t` to `int`, so that the
field `f : t` looks like `f : int` when we do the lookup. Instead of
cluttering the typechecker with this sort of thing, this translation is
now done implicitly on field lookup.
@supercooldave
Copy link

Argh. I'll never the get type synonyms done if you keep changing things!!

@EliasC
Copy link
Contributor Author

EliasC commented Apr 6, 2016

@supercooldave: I'm fine with postponing this merge until the type synonyms are done, and then the problem is mine to fix instead! My guess is that if anything this refactoring should make things simpler.

@supercooldave
Copy link

@EliasC I can see whether this causes any chaos – I was mainly moaning because I'd just managed to finish processing the last batch of changes to get type synonyms up to date.

@supercooldave supercooldave merged commit 5be8d71 into parapluu:development Apr 7, 2016
@supercooldave supercooldave deleted the fix/bindings-refactoring branch April 7, 2016 06:33
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