Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions crates/move-stackless-bytecode/src/dynamic_field_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,15 +601,23 @@ impl FunctionTargetProcessor for DynamicFieldAnalysisProcessor {

fn finalize(&self, env: &GlobalEnv, targets: &mut FunctionTargetsHolder) {
// Collect and combine all functions' dynamic field info
let combined_info = DynamicFieldInfo::iter_union(targets.specs().filter_map(|fun_id| {
let combined_info = DynamicFieldInfo::iter_union(
targets
.get_data(&fun_id, &FunctionVariant::Baseline)
.and_then(|data| {
data.annotations
.get::<DynamicFieldInfo>()
.map(|info| info.clone())
})
}));
.specs()
.copied()
.chain(targets.get_funs().filter(|fun_id| {
targets.is_pure_fun(fun_id) || targets.is_abort_check_fun(fun_id)
}))
.filter_map(|fun_id| {
targets
.get_data(&fun_id, &FunctionVariant::Baseline)
.and_then(|data| {
data.annotations
.get::<DynamicFieldInfo>()
.map(|info| info.clone())
})
}),
);

// Set the combined info in the environment
env.set_extension(combined_info);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module 0x42::foo;

use prover::prover::{requires, ensures};

use sui::dynamic_field;

public struct Foo has key {
id: UID,
}

#[ext(pure)]
fun has_field(x: &Foo): bool {
dynamic_field::exists_with_type<u64, u8>(&x.id, 10)
}

fun foo(x: &mut Foo) {
dynamic_field::add<u64, u8>(&mut x.id, 10, 42);
}

#[spec(prove)]
fun foo_spec(x: &mut Foo) {
requires(!dynamic_field::exists_with_type<u64, u8>(&x.id, 10));
foo(x);
ensures(has_field(x));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: crates/sui-prover/tests/integration.rs
expression: output
---
Verification successful