I'm opening this because it appears issue 6549 has been closed due to a more specific interpretation than I had intended. (But the fix is already a win.)
Currently, code like the following is rejected:
int foo(int x)
in{assert(x<0);}
out(result){assert(result>0);}
tt.di(2): Error: function `tt.foo` `in` and `out` contracts can only appear without a body when they are virtual interface functions or abstract
This is still an arbitrary restriction, because contracts logically belong to the function declaration. (You can interpret the contracts as a restriction of the argument/return types, so it makes little sense to allow argument/return types but not contracts.)
Such code should be accepted. This may require changing name mangling so it contains a hash of the contracts.
Comment #1 by robert.schadek — 2024-12-13T19:13:49Z