Skip to content

Fix bug in handling of blocks that occur in expresssions#672

Open
keyboardDrummer wants to merge 15 commits intomainfrom
fixImpureExpressionBlockHandling
Open

Fix bug in handling of blocks that occur in expresssions#672
keyboardDrummer wants to merge 15 commits intomainfrom
fixImpureExpressionBlockHandling

Conversation

@keyboardDrummer
Copy link
Copy Markdown
Contributor

@keyboardDrummer keyboardDrummer commented Mar 26, 2026

Changes

  • Fix bug in handling of blocks that occur in expressions. The heart of the problem was that transformStmt, which does not update the substitution map, was being called from inside transformExpr when it was handling a block, leading to missing substitutions. A second but smaller bug was a statement ordering bug that occurred when handling calls.

Testing

  • Added test-case

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@keyboardDrummer keyboardDrummer requested review from a team and olivier-aws March 26, 2026 10:49
joscoh
joscoh previously approved these changes Mar 26, 2026
Copy link
Copy Markdown
Contributor

@joscoh joscoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the PR with a short description of what the bug is?

@keyboardDrummer keyboardDrummer requested a review from joscoh March 26, 2026 16:55
@keyboardDrummer keyboardDrummer requested a review from joscoh March 27, 2026 08:54
// The next statement is not translated correctly.
// I think it's a bug in the handling of StaticCall
// Where a reference is substituted when it should not be
// var z: int := addProc({x := 1; x}, {x := x + 10; x}) + (x := 3);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the bug only affecting the case addProc, or also with add?

Copy link
Copy Markdown
Contributor Author

@keyboardDrummer keyboardDrummer Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think anything with .StaticCall, so both I'm not sure

Comment on lines -25 to -34
composite Box {
var value: int
}

procedure heapUpdateInBlockExpr(b: Box)
{
var x: int := { b#value := b#value + 1; b#value };
assert x == b#value
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this test?

Copy link
Copy Markdown
Contributor Author

@keyboardDrummer keyboardDrummer Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file only applies a single phase from the Laurel pipeline, and that phase does not support the program in this test, since it uses field access which should've already been lowered at that point. Not sure how it was working before.

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.

3 participants