Issue 3563 #4376

wants to merge 3 commits into


None yet
2 participants

catamorphism commented Jan 8, 2013

r? @nikomatsakis This patch causes self to be inherited from the enclosing function context when typechecking nested closures, allowing default methods to call inherited methods on self. This is effectively treating self like it has dynamic scope, for the purposes of typechecking. I think it should be sound to do so, since any incorrect uses of self would already have been flagged by resolve.

This addresses #3563.

catamorphism added some commits Jan 8, 2013

@catamorphism catamorphism Improve a typeck ICE 485c839
@catamorphism catamorphism Suppress error messages about function types whose result is ty_err
Ideally we would suppress error messages involving any types that
contain ty_err, but that's awkward to do right now.
@catamorphism catamorphism Treat `self` as if it's dynamically scoped when typechecking nested f…

Necessary to allow supertrait methods to be called in default functions.

As per #3563

catamorphism commented on 485c839 Jan 8, 2013

oops, memo to self: rebase this before committing, it really needs to be part of be06a3e


nikomatsakis commented Jan 8, 2013

Let me think about this more carefully for a sec, but it looks correct.

One caveat: this is not dynamic scoping. Dynamic scoping would mean that the body of some called function would see values set by the caller --- but this is just saying that self is available as an upvar to closures within, which I think is reasonable. In fact it's already the case, but incompletely, which is what you're fixing I guess.


nikomatsakis commented Jan 8, 2013

r+ --- I think this is reasonable.


catamorphism commented Jan 8, 2013

Merged - 80435ad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment