Skip to content

Refactor typechecker to hide type substitution#361

Merged
supercooldave merged 1 commit into
parapluu:developmentfrom
EliasC:fix/bindings-refactoring
Apr 7, 2016
Merged

Refactor typechecker to hide type substitution#361
supercooldave merged 1 commit into
parapluu:developmentfrom
EliasC:fix/bindings-refactoring

Conversation

@EliasC
Copy link
Copy Markdown
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
Copy Markdown

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

@EliasC
Copy link
Copy Markdown
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
Copy Markdown

@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