Issue 3563 #4376

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

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.
f428405
@catamorphism catamorphism Treat `self` as if it's dynamically scoped when typechecking nested f…
…unctions

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

As per #3563
be06a3e
Owner

catamorphism commented on 485c839 Jan 8, 2013

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

Contributor

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.

Contributor

nikomatsakis commented Jan 8, 2013

r+ --- I think this is reasonable.

Contributor

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