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 #59. Bug/restoring self #65

Merged
merged 3 commits into from
Dec 9, 2017
Merged

Fixes #59. Bug/restoring self #65

merged 3 commits into from
Dec 9, 2017

Conversation

faultyserver
Copy link
Member

There were a number of cases where the flow of control through the interpreter bypasses the normal logic for managing the self_stack. Namely, this was an issue with raise and break, where the implementation uses Crystal exceptions to panic up the callstack.

The solution was to manually save the state of self_stack before entering an ExceptionHandler or Invocation, then manually restore it when these flow control expressions are encountered.

See #59 for a slightly more in-depth description of the issue.

Invoking `to_s` on the given value returns a TString (since it's a potentially-in-language method). This value was not being unwrapped when printing the message, meaning the output for errors would almost always look like "no variable or method for <Myst::TString#...>:List", which is confusing and not helpful.
When an exception is raised in the language, all of the normal logic for managing the self stack is bypassed, meaning that raising an error could/would leave the self stack in an incorrect state.

This commit adds logic to restore the self stack whenever an exception is rescued to what it was upon visiting the ExceptionHandler node.
@faultyserver faultyserver added this to the Next milestone Dec 9, 2017
Similar to rescuing from a `raise`, `break` similarly bypasses the normal logic for managing `self`, so it must be manually added.
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