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

Issue 3563 #4376

Closed
wants to merge 3 commits into from
Closed

Issue 3563 #4376

wants to merge 3 commits into from

Conversation

catamorphism
Copy link
Contributor

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.

Ideally we would suppress error messages involving any types that
contain ty_err, but that's awkward to do right now.
…unctions

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

As per rust-lang#3563
@nikomatsakis
Copy link
Contributor

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
Copy link
Contributor

r+ --- I think this is reasonable.

@catamorphism
Copy link
Contributor Author

Merged - 80435ad

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