Allow proof blocks inside proof fn (fixes #2061)#2249
Open
nitrotap wants to merge 1 commit into
Open
Conversation
ce807da to
529659b
Compare
Previously, `proof { }` blocks inside `proof fn` produced a confusing
error: "proof blocks inside spec code is currently supported only for
spec functions with decreases". This was because the macro layer used
a single `inside_ghost` counter for both spec and proof functions.
This fix:
- Adds `inside_spec` tracking to distinguish spec fn from proof fn
- Emits `proof_in_spec` only for spec functions (for termination checking)
- Emits `proof_block` for proof functions (treating them as redundant but allowed)
- Updates modes.rs to allow proof blocks when already in ghost mode
529659b to
f8536cf
Compare
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
Fixes #2061
proof { }blocks insideproof fnpreviously produced a confusing error: "proof blocks inside spec code is currently supported only for spec functions with decreases". This was because the macro layer used a singleinside_ghostcounter for both spec and proof functions, causing proof blocks in proof functions to be incorrectly marked asproof_in_spec.Changes
builtin_macros/src/syntax.rs— Addinside_spectracking to distinguish spec fn from proof fn. Only emitproof_in_specfor actual spec functions; emitproof_blockfor proof functions.vir/src/modes.rs— Allow proof blocks when already in ghost mode (redundant but harmless)rust_verify_test/tests/proof_in_spec.rs— Update 3 tests, add 8 new tests for issue bad error msg for proof block in proof fn #2061Test plan
vargo build --release— 1490 verified, 0 errorsvargo test --vstd-no-verify -p rust_verify_test --test proof_in_spec— 38 passedvargo test --vstd-no-verify -p rust_verify_test --test modes— 115 passed