Merge functions and procedures in Laurel#28
Conversation
…opaqueSpec - Changed procedureToOp to produce opaqueSpec op with ensures and modifies as nested args (matching the grammar), instead of separate top-level args - Added missing opaque keyword in MapStmtExprTest and T2_ModifiesClauses tests
…lator - Add `axioms : List StmtExprMd` field to Laurel's Procedure structure - In ContractPass, build axiom expressions from invokeOn trigger + ensures clauses (nested Forall with trigger on innermost quantifier), then clear the invokeOn field - Update LaurelToCoreTranslator to translate proc.axioms directly instead of using the now-removed translateInvokeOnAxiom function - Update CoreGroupingAndOrdering to use axioms instead of invokeOn for procedure ordering and callee collection - Update Resolution to preserve axioms through name resolution - Update MapStmtExpr to traverse axioms in mapProcedureM - Fix InvokeOn test expected error messages
…transparent-statement-bodies
- Grammar: Add `modifiesWildcard` op for `modifies *` syntax - Parser: Handle `modifiesWildcard` by producing `StmtExpr.All` in modifies list - Printer: Emit `modifiesWildcard` when modifies list contains `All` - ModifiesClauses: Skip frame condition generation for wildcard modifies - FilterNonCompositeModifies: Preserve `All` entries (don't filter as non-composite) - HeapParameterization: Don't treat wildcard `All` as evidence of heap access - PythonToLaurel: Use `modifies *` for all opaque procedures - Specs/ToLaurel: Use `modifies *` for spec procedures - T2_ModifiesClauses: Uncomment wildcard test case
…ontract-and-proof-pass
Two issues were causing the Python test failures: 1. dbg_trace statements in LaurelCompilationPipeline.lean were printing massive debug output that polluted #guard_msgs test expectations. 2. The contract pass (ContractPass.lean) created Assert/Assume nodes with source := none (via mkMd). When these reached the Core translator, getNameFromMd triggered 'BUG: metadata without a filerange' debug traces, further polluting test output. Fix: propagate source locations from the original preconditions and body to the Assert/Assume/Block nodes created by transformProcBody.
Prefix `program` parameter with underscore to suppress the 'unused variable' warning that causes the docs build to fail with --wfail.
Formatting improvements:
- Change block formatting to use indent(2) with newlines for vertical layout
instead of single-line '{ ... }' format
- Update semicolon separator to use newlines instead of spaces
Debugging improvements:
- Replace boolean 'coreProgramHasSuperfluousErrors' with 'coreDiagnostics' list
that records why the Core program was suppressed, enabling better error surfacing
- Add source location and reason parameters to 'invalidCoreType' for more
informative diagnostics
- Surface core diagnostics when no other diagnostics explain program suppression
- Add 'processLaurelFileKeepIntermediates' test helper for writing intermediate
pipeline files to Build/ directory
- Add Build/ to .gitignore
Test updates:
- Update all expected outputs to match new block formatting
- Add 'opaque' keyword to test procedures that need it for the new formatting
- Fix #guard_msgs whitespace formatting
Diagnostics with FileRange.unknown are not actionable for users and can arise from pre-existing resolution limitations (e.g., variables in multi-assign with field targets losing their uniqueId). Filter these out when surfacing suppression reasons to avoid spurious errors.
The CodeBuild source location was hardcoded to strata-org/Strata.git, which fails when the commit only exists in keyboardDrummer/Strata. Use github.server_url/github.repository so it resolves to the correct repo dynamically.
The CodeBuild project has credentials for strata-org/Strata only. On forks like keyboardDrummer/Strata, the job cannot access the source. Add an 'if' condition to skip the benchmark on non-upstream repos, and restore the hardcoded source URL that CodeBuild expects.
…gging-improvements # Conflicts: # Strata/Languages/Laurel/LaurelToCoreTranslator.lean
…t emitDiagnostic - Remove the FileRange.unknown filter in LaurelCompilationPipeline: all coreDiagnostics are now surfaced when no other diagnostics explain the suppression. - Remove default parameters from invalidCoreType, making source and reason explicit at every call site. - Remove redundant emitDiagnostic in the catch-all arm of translateType: invalidCoreType already records the diagnostic via coreDiagnostics.
Diagnostics without a known source location are not actionable for the user. Restore the filter that was removed in 0b6cee4 to fix the T1_MutableFields test failure.
|
@keyboardDrummer-bot can you create another PR that is a copy of this PR, but without the first two phases: You might run into issues with assertions not being lifted in the lifting pass. |
|
I've created PR #45 as requested — it's a copy of this PR without the The PR includes the fixes from strata-org#1113 (HeapParam scope bug) and strata-org#1130 (lift imperative call prepend ordering) since those were already part of this PR's changes. Key changes from this PR:
Some tests may need adjustment since without the contract pass:
|
|
@keyboardDrummer-bot please update the contract pass in this PR so it mimics the design of #34. In particular: |
…put params Key changes: - $post procedures are functional (isFunctional := true) - $post takes all inputs AND all outputs as parameters - $post does not call the original procedure — returns conjunction of postconditions over the combined input+output parameters - At call sites, input arguments are assigned to temporary variables; those temps are passed to both the actual call and the assumed $post call (along with the output variables after the call)
|
I investigated the CI failures and pushed a fix (860a1f1) that resolves some of the test regressions. Here's a summary: Fixed (3 tests now pass):
Key fix — ContractPass Remaining failures (pre-existing issues exposed by the contract/transparency pass interaction):
|
|
I pushed a fix (c6bfe97) that resolves the CI failures caused by the transparency pass incorrectly demoting functional procedures (like Root cause: The transparency pass was only keeping contract-generated functions (with Fix: Changed the transparency pass to keep ALL Remaining 3 test failures (T1_MutableFields, T2_ModifiesClauses, T2_ImpureExpressions) are pre-existing issues that were already failing before this commit but were masked by the
|
CI Failure InvestigationI investigated the 3 failing tests on the latest push ( Failing tests
Root cause for T2_ImpureExpressions and T1_MutableFieldsThe transparency pass change in
The previous filter ( Root cause for T2_ModifiesClausesLines 45 and 107 contain assertions like NoteThese 3 failures are pre-existing — they were already present at commit |
…ontract-and-proof-pass
c6bfe97 to
87a87cd
Compare
Builds on:
Functional changes
Implementation
Add these passes:
returntoexitstatements, needed for the next pass.$asFunction. If a Core procedure is marked as transparent, attempt to generate a functional version of it, where assertions are erased and all calls are to functional versions. Tie the functional version to the procedure using a free postcondition.Why can't we have a PR with just the contract or just the transparency pass?
Follow-up work