Open bobismijnnaam opened 1 year ago
Overloading seems order-dependent indeed, at least in the implementation for C. In the example below it verifies successfully even though the postcondition of main()
should be false. If the postcondition of main()
is changed to \result == 6
it does not verify. It does seem to know that incr(int a)
exists, otherwise I would expect an error in the body of main()
, but for verifying it seems to grab the contract of the first method with the correct name without taking parameters into account.
//@ ensures \result == 5;
int incr() {
return 5;
}
//@ ensures \result == 6;
int incr(int a) {
return 6;
}
//@ ensures \result == 5;
int main() {
return incr(7);
}
VerCors generally assumes that the example compiles. In the case of C programs, it is not legal to redefine declarations in C, so for C VerCors just takes the first declaration that is named correctly. As you may know there is no concept of overloading in C, so the resolution does not account for selecting a declaration with the correct shape of arguments. It seems that the error you are expecting is unfortunately missing, there should be a structural check that the number of given arguments matches the declaration. It seems the argument is silently dropped somewhere in the rewrite chain.
Bob's example is written in Java, where we do consider overloading and the shape of the arguments. It appears that there is a type rule that coerces integers into (our current flawed interpretation of) floats. This should be resolved by any concerted effort to improve our support for floats :)
The following input:
Yields:
I would expect it to pass (besides the unsat error, that's expected), since the type of
2
isint
. I guess I either made a mistake when implementing floats or the overloading resolving system was order-dependent to begin with.