-
Notifications
You must be signed in to change notification settings - Fork 38
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
Two fixes for Paxos simulation #1276
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like incrementing and decrementing the depth counter across multiple classes is a bit a fragile solution. Would not it make sense to introduce higher-level methods like init()
, enterDef
, exitDef
?
visitor.definitionDepth = -1 | ||
walkDefinition(visitor, decl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I am a bit lost in the difference between top-level and inner definitions. Would not that code get triggered on both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top-level definitions are declarations, while inner definitions are NOT declarations. This is inside walkDeclaration
, so the code would only be called right before walking top level definitions.
This fixes the problem on the Apalache side, according to a test I just ran locally. 💃. |
if (visitor.definitionDepth !== undefined) { | ||
visitor.definitionDepth++ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it mean if definitionDepth
is undefined here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means that the class (the concrete visitor) doesn't care about definitionDepth
(it doesn't define or use it).
Co-authored-by: Shon Feder <shon@informal.systems>
I can't think of a better way to implement the
Do you think any of this two approaches are worth implementing? Or perhaps have a better idea to abstract this? |
I suggest going with your approach to fix the bugs, as I don't see it adding more complexity. It is just correcting the implementation and if it makes complexity more apparent it is only the complexity that is already required by our approach. The other approaches you suggest seem worth considering, but we can address those in a followup issue, exploring the trade offs there. WDYT? |
I would like to avoid this one especially. It would be much harder to compose definitions, if we have to keep track of their depth. |
This is probably the cleanest solution. After all, this is exactly what we need lookup tables for: To get all additional data without computing it ever again. |
Hello
This includes 2 changes that make
test
for Paxos get a ✅ (even though it has no tests, we had failures before):IRTransformer
to transform the types inside the sum type fields. There was also a related problem with printing that was fixed, and tests were updated accordingly.assume
were not being flattened correctly, because the way we trackdefinitionDepth
was not consideringassume
(or instance overrides, which could also introduce the same issue). Solution:definitionDepth
now is also incremented inside top level declarations. It is a bit tricky, and this is used in 4 different visitors, so instead of adding complexity to all of them, I moved handling ofdefinitionDepth
to theIRVisitor
interface and itswalk*
functions.This has the potential to help @shonfeder's work on making sumtypes work in Apalache, since the problem there seems to be related to (1).
CHANGELOG.md
for any new functionalityREADME.md
updated for any listed functionality