tim: Tim with short hair, smiling, wearing a black jacket over a white T-shirt (Default)
[personal profile] tim
I finished one pull request, which fixes 3563 and got most of the way along to finishing another, that one for issue 3979.

Both issues involve default methods, which are a new feature that's not quite baked yet (so much so that for 0.5, we turned it off by default). #3563 had a couple of test cases attached; in the simplest one, calling a non-existent method on self inside a default method would cause an internal compiler error during typechecking. This turns out to be because the typechecker assumes that anything with the type self is the value self (a special name that refers to the self object inside either an implementation of a trait, or a default method in a trait). The simplest fix for this I could see was to treat self as if it has dynamic scope, just for typechecking purposes. That is, instead of throwing away the self ID from the enclosing scope when typechecking a nested closure, keep the same one, so closures inside default methods can refer to self. This seems a little bit dirty (as if it might enable out-of-scope uses of self), but I *think* it's okay because in the Rust compiler, name resolution is a separate pass from typechecking, and happens first. So if you tried to do something fishy with self, resolve would catch it before typechecking ever happened.

Issue 3979 showed that you couldn't call a supertrait method inside a default method. After quite a bit of fumbling, I fixed the test case shown in the issue report, but while working on it I noted to myself that I should check at least two more cases (supertraits with type parameters, and the case where you define the traits in a separate crate from the impls of them). Once I wrote those two test cases and ran them, it turned out neither of them works. So I can't submit this one quite yet (in good conscience).
From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User (will be screened if not on Access List)
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

tim: Tim with short hair, smiling, wearing a black jacket over a white T-shirt (Default)
Tim Chevalier

March 2014

S M T W T F S
      1
2345678
9101112131415
16171819202122
23 24252627 2829
3031     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags