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

Fixes #109. Fix closure handling in various corner cases. #132

Merged
merged 2 commits into from
Jan 27, 2018

Conversation

faultyserver
Copy link
Member

@faultyserver faultyserver commented Jan 27, 2018

Invocation was incorrectly determining the value of self to use when calling a function. Before #131, it was only checking if the Call had a receiver, and would use that value if it did. After #131, if the Call did not have a receiver, it would then check if the functor was a closure, and use the closed value of self if it was.

Now, Invocations always perform both checks, with closures taking higher precedence than Call receivers (though, both will be pushed to the stack if the conditions are met).

Before this PR, I was very confused why static methods weren't working while non-static methods were. I assumed it was an issue with scope vs instance_scope on Types or something like that, but had no idea.

Now, though, I'm even more confused how any case was working previously, as the Call receiver was always being pushed as the value of self. At least with this version of the code, the value of self that will be present is more explicit and well-specified. ¯_(ツ)_/¯

This PR also required making some changes to the Spec library to deal with the changes in semantics of what self will be within various Calls.

…r blocks on static methods.

`Invocation` was incorrectly determining the value of `self` to use when calling a function. Before myst-lang#131, it was only checking if the Call had a receiver, and would use that value if it did. After myst-lang#131, if the Call did _not_ have a receiver, it would then check if the functor was a closure, and use the closed value of `self` if it was.

Now, Invocations _always_ perform both checks, with closures taking higher precedence than Call receivers (though, both will be pushed to the stack if the conditions are met).

Before this commit, I was very confused why static methods weren't working while non-static methods were. I assumed it was an issue with `scope` vs `instance_scope` on Types or something like that, but had no idea.

Now, though, I'm even more confused how _any_ case was working previously, as the Call receiver was _always_ being pushed as the value of `self`. At least with this version of the code, the value of `self` that will be present is more explicit and well-specified. ¯\_(ツ)_/¯
…self`.

Const lookup was only operating on the current scope and current `self`, rather than looking at the full lexical scope as well. Const lookup now does full recursive lookup (like a Call) to properly resolve in most cases.

This commit also makes some changes to the Spec library to work with the new semantics of capturing `self` with closures.
@faultyserver faultyserver added this to the Next milestone Jan 27, 2018
@faultyserver
Copy link
Member Author

I'm not entirely sure, but this seems like it will be a breaking change (at least in combination with #131) for the next release. Not an issue, just a note.

@faultyserver faultyserver merged commit f82fdbf into myst-lang:master Jan 27, 2018
@faultyserver faultyserver deleted the bug/nested_static_blocks branch January 27, 2018 04:57
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.

1 participant