creusot icon indicating copy to clipboard operation
creusot copied to clipboard

Nothing enforces that #[logic]/#[law]/#[predicate] attributes are the same in a trait declaration and in implementation.

Open jhjourdan opened this issue 2 years ago • 8 comments

Creusot display no error messge for, e.g:

extern crate creusot_contracts;

use creusot_contracts::*;

trait T {
    #[law]
    #[ensures(x == x)]
    fn l(x: Self);
}

impl T for u32 {
    // #[law]
    #[ensures(y == y)]
    fn l(y: Self) {}
}

Or:

extern crate creusot_contracts;

use creusot_contracts::*;

trait T {
    #[logic]
    #[ensures(x == x)]
    fn l(x: Self);
}

impl T for u32 {
    // #[logic]
    #[ensures(y == y)]
    fn l(y: Self) {}
}

Or:

extern crate creusot_contracts;

use creusot_contracts::*;

trait T {
    // #[logic]
    #[ensures(x == x)]
    fn l(x: Self);
}

impl T for u32 {
    #[logic]
    #[ensures(y == y)]
    fn l(y: Self) {}
}

And so on.

jhjourdan avatar May 31 '22 12:05 jhjourdan

True, but we need to make sure to leave holes for special traits like Add, Index etc

xldenis avatar May 31 '22 13:05 xldenis

I see, so #403 is a dependency for this.

jhjourdan avatar May 31 '22 13:05 jhjourdan

Even then, we will need to special case Deref at the very least, but yes.

xldenis avatar May 31 '22 13:05 xldenis

Is this just because of Ghost ?

jhjourdan avatar May 31 '22 13:05 jhjourdan

In large part, but actually many functions are implicitly using this especially in top level contracts.

xldenis avatar May 31 '22 13:05 xldenis

It's not hard to special case these, in fact they already are.

xldenis avatar May 31 '22 13:05 xldenis

I don't know what you mean by "special case", but at some point we will need to make sure we do not call program functions in specifications...

jhjourdan avatar May 31 '22 13:05 jhjourdan

That's already the case: we check that all functions called in logical programs are pure (or are one of a small list of traits we 'overload'). We just need to allow those traits to be the only ones which allow impls to be logical despite the trait signature being a program function.

xldenis avatar May 31 '22 13:05 xldenis