Skip to content

Closures inside #[pure] functions trigger "impure function" and "unsupported constant type" errors #1543

@lynae99

Description

@lynae99

Using a closure inside a function marked with #[pure] causes Prusti to report that std::ops::Fn::call is impure. It also triggers an unsupported constant type error for the closure itself.
Reproduction

use prusti_contracts::*;

#[pure]
fn check() -> bool {
    // A trivial closure inside a pure function
    (|| { true })()
}

fn main() {}

Actual Behavior
Prusti reports the following errors:

  1. error: [Prusti: invalid specification] use of impure function "std::ops::Fn::call" in pure code is not allowed
  2. error: [Prusti: unsupported feature] unsupported constant type ... Closure(...)

Expected Behavior
Trivially pure closures (like the one above) should be accepted inside #[pure] functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions