Add EliminateReturnStatements and ContractPass with functional $post#35
Draft
keyboardDrummer-bot wants to merge 2 commits intoissue-21-assign-variable-typefrom
Draft
Add EliminateReturnStatements and ContractPass with functional $post#35keyboardDrummer-bot wants to merge 2 commits intoissue-21-assign-variable-typefrom
keyboardDrummer-bot wants to merge 2 commits intoissue-21-assign-variable-typefrom
Conversation
…procedures EliminateReturnStatements: rewrites return statements to exit statements, needed for the contract pass. ContractPass: translates away pre and postconditions by introducing assertion and assumptions at call sites and at procedure starts and ends. Key differences from the original PR #28 contract pass: - $post procedures are marked as functional (isFunctional := true) - $post procedures take all inputs AND all outputs as parameters, so they don't need to call the original procedure in their body - At call sites, input arguments are first assigned to temporary variables, which are then passed to both the call and the assumed $post invocation
Collaborator
Author
|
The "Run internal benchmarks of Strata" CI failure is not caused by the code changes in this PR. I verified:
The benchmark failure is a pre-existing infrastructure issue affecting all PRs in this fork. I confirmed that PRs #33, #34, and #36 (including completely unrelated changes) all have the same benchmark failure while all other checks pass. The CI workflow's No code fix is needed for this PR — the benchmark job configuration would need to be updated to reference the correct repository for fork PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Copies two passes from PR #28 with modifications to the contract pass as requested:
EliminateReturnStatements (copied as-is)
Rewrites
returnstatements toexitstatements by wrapping procedure bodies in a labelled block. This ensures code placed after the body (e.g., postcondition assertions) is always reached.ContractPass (modified)
Translates away pre and postconditions entirely by introducing assertions and assumptions at call sites and at procedure starts and ends.
Key differences from PR #28's contract pass:
$postprocedures are marked as functional (isFunctional := true) — they are pure functions.$postprocedures take all inputs AND all outputs as parameters — so they don't need to call the original procedure in their body. For a procedurefoo(a, b) returns (x, y)with postconditionP(a, b, x, y), generates:At call sites, input arguments are assigned to temporary variables first, then those temps are passed to both the call and the assumed
$post:This ensures the postcondition assumption references the pre-call argument values even if the call modifies mutable variables.