Skip to content

Fold/unfold error with snapshot equality #1134

Open
@zgrannan

Description

@zgrannan

Triggered by the following:

use prusti_contracts::*;

#[derive(Clone, Copy)]
struct Inner(u32);

#[derive(Clone, Copy)]
struct Outer {
    inner: Inner,
}

#[ensures(out.inner === out.inner)]
fn go(out: Outer) {
}


fn main(){}

Yields:

error: [Prusti internal error] Prusti encountered an unexpected internal error
  --> min.rs:12:1
   |
12 | / fn go(out: Outer) {
13 | | }
   | |_^
   |
   = note: We would appreciate a bug report: https://github.com/viperproject/prusti-dev/issues/new
   = note: Details: cannot generate fold-unfold Viper statements. The required permission Pred(old[pre]((unfolding acc(Ref(struct$m_Outer)(_1), write) in _1.f$inner)), read) cannot be obtained.

Some observations:

  • The nested struct seems to be part of the problem (changing inner to be just a u32 allows this to pass)
  • Changing ensures to requires allows this to pass

I think this is likely related to the old() expression being introduced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already existsfold-unfoldThis is an issue with the fold-unfold algorithm in Prusti

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions