Skip to content

Conversation

@keyboardDrummer
Copy link
Member

@keyboardDrummer keyboardDrummer commented Oct 7, 2024

Fixes #5808

Description

  • Add a call to new MatchFlattener(reporter).PostResolve(module); after cloning elements for abstract imports, so .Flattened is set.
  • Fix the behavior of the afterChildren parameter in Node.Visit, so that closure is actually only called after the children are visited.

How has this been tested?

Added a CLI test

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Alternatively, we could call all the rewriter.PostResolve methods
*/

new MatchFlattener(reporter).PostResolve(module);
Copy link
Member Author

Choose a reason for hiding this comment

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

This added line is the only semantic change in this PR

@keyboardDrummer keyboardDrummer changed the title Unreachabel expr to boogie Fix a bug related to abstract imports and match expressions Oct 7, 2024
@keyboardDrummer keyboardDrummer enabled auto-merge (squash) October 7, 2024 14:27
Comment on lines +165 to +166
void AfterNodeChildren() => afterChildren(currentNode);
toVisit.AddFirst((Action)AfterNodeChildren);
Copy link
Member

Choose a reason for hiding this comment

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

Nice fix, funny how simple and clean the original looks while also being completely wrong. :)

Cloning with resolved fields is not an option,
because then internal references of the cloned code can point to the old code.
I(keyboardDrummer) think it would be better altogether if no cloning was done for abstract modules,
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity what alternative do you imagine? Given the semantics of abstract modules are so close to the idea of making copies of the code, could the better path be doubling-down on clone testing? I don't feel like cloning is going away any time soon.

Copy link
Member Author

@keyboardDrummer keyboardDrummer Oct 8, 2024

Choose a reason for hiding this comment

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

Whatever operation you want to do on both the abstract module and the original module, where the two should behave mostly the same but somewhat differently, pass in a context object that allows you to differentiate between the two scenarios.

Given that I don't understand the code related to abstract modules, I would probably find related tests, reimplement without copying and see what breaks.

@keyboardDrummer keyboardDrummer merged commit cde4a05 into dafny-lang:master Oct 7, 2024
22 checks passed
@keyboardDrummer keyboardDrummer deleted the unreachabelExprToBoogie branch October 8, 2024 09:11
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.

Internal error during verification

2 participants