feat: rich external loop invariant error messages#342
Merged
andrii-a8c merged 4 commits intomainfrom Nov 12, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances error messages for external loop invariant validation by adding a list of available variables when a parameter mismatch is detected. This makes debugging easier by showing developers what variables they can actually use in their loop invariant functions.
Key Changes:
- Added helper function to parse variable names by stripping internal compiler suffixes
- Enhanced error message to include list of available variables when parameter not found
- Updated test snapshot to reflect the improved error message format
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/move-stackless-bytecode/src/move_loop_invariants.rs | Added parse_var_name helper function and enhanced error message to list available variables |
| crates/sui-prover/tests/snapshots/loop_invariant/external_invalid_arg_name.move.snap | Updated test snapshot to reflect new error message format with available variables list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
msaaltink
reviewed
Nov 12, 2025
| let res = test_loop!(n); | ||
| ensures(res == (n as u128) * ((n as u128) + 1) / 2); | ||
| res | ||
| } |
Collaborator
There was a problem hiding this comment.
Perhaps add something like
fun map_test(v: &vector<u8>) {
let u = v.map!(|x| 0);
assert(u.length() == v.length());
}
#[spec_only(loop_inv(target=map_test))]
fun map_loop_inv(i: u64, stop: u64, v: vector<u8>) {
i <= stop && v.length() == stop - i
}
#[spec(prove)]
fun map_test_spec(v: &vector<u8>) {
map_test(v);
}
Collaborator
Author
Contributor
There was a problem hiding this comment.
eventually there should be a loop, maybe in v.length().do!
BigBadE
pushed a commit
that referenced
this pull request
Nov 19, 2025
* feat: rich error messages * cleanup * cleanup * feat: added types and 1 more test
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.

No description provided.