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

Fix problems with blocks in variable declaration expressions #345

Merged
merged 2 commits into from Apr 10, 2020

Conversation

smarr
Copy link
Owner

@smarr smarr commented Apr 7, 2020

This fixes an issue with using blocks in variable declarations:

public testSelfInBlock = (
      | var = [ self ] value. |
      self assert: var is: self.
)

Before the PR, the block caused an exception, caused by how we manage variables on the MethodScope objects.

We expect them to be set exactly once, when the variable declaration parsing is completed.

However, if we have a block, the block needs a marker for us to know whether it's on the stack, which is an Internal variable added to the variable array.
The array may have been set (if we have a block in the method after the variable declarations), or it may not have been set yet (if we have a block in the variable declarations).
This fixes the error when we haven't set the variables yet.

@daumayr @sophie-kaleba could one of you review this and approve the PR, or suggest improvements, perhaps missing tests?

These tests cause frameOnStack marker variables to be inserted into the local variables, which crashes because how variables are expected to be set.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
This ensures that we can use blocks inside of variable declaration delimiters.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
@smarr smarr added the bug Fixes an issue, incorrect implementation label Apr 7, 2020
@smarr smarr added this to the v0.8.0 milestone Apr 7, 2020
@smarr smarr added this to Open Issues in Completeness via automation Apr 7, 2020
@smarr smarr merged commit 21c08a6 into dev Apr 10, 2020
Completeness automation moved this from Open Issues to Completed Apr 10, 2020
@smarr smarr deleted the self-in-locals branch April 10, 2020 22:18
@smarr
Copy link
Owner Author

smarr commented Apr 10, 2020

If you have comments, or suggestions for improvements, I'll create a new PR.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes an issue, incorrect implementation
Projects
No open projects
Completeness
  
Completed
Development

Successfully merging this pull request may close these issues.

None yet

1 participant