Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[open] functions and termination #1338

Open
arnaudgolfouse opened this issue Feb 3, 2025 · 1 comment
Open

#[open] functions and termination #1338

arnaudgolfouse opened this issue Feb 3, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@arnaudgolfouse
Copy link
Collaborator

It would be nice to special-case #[open] logical functions during the termination check. To see why, consider the following example:

pub trait Tr: Sized {
    #[logic]
    fn property(self) -> Int;

    #[logic]
    #[requires(bar(self))]
    fn foo(self);
}

#[logic]
#[open]
pub fn bar<T: Tr>(x: T) -> bool {
    x.property() == 42
}

impl Tr for () {
    #[logic]
    #[open]
    fn property(self) -> Int { 1 }

    #[logic]
    #[open]
    #[requires(bar(self))]
    fn foo(self) {}
}

Creusot reject this:

error: Mutually recursive functions: when calling `<() as Tr>::foo`...
  --> test.rs:29:5
   |
29 |     fn foo(self) {}
   |     ^^^^^^^^^^^^
   |
note: then `<() as Tr>::foo` might call `<() as Tr>::foo` via the call to `bar`.
  --> test.rs:28:16
   |
28 |     #[requires(bar(self))]
   |                ^^^^^^^^^

And, well, it is right to: bar is asking for an implementation of <() as Tr>, which we are in the process of defining.

But the function is open... So it would make sense to have its callers 'see' that it only calls specific functions, and not the whole implementation.

@jhjourdan
Copy link
Collaborator

Agreed. I think we already discussed this, but I'm not sure we wrote an issue about this.

@jhjourdan jhjourdan added the enhancement New feature or request label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants