Comment #0 by verylonglogin.reg — 2015-06-23T08:46:04Z
This code compiles but shouldn't:
---
void f(int[] arr)
in { arr[0] = 5; } // compiles, should be an error
body { }
class C
{
int i;
void f()
in { i = 5; } // compiles, should be an error
body { }
}
---
Notes:
`invariant` doesn't allow modification of class fields as `this` is `const` and function result passed to `out` contract is `const` too. For `in`/`out` contracts only direct assignment to parameter is rejected (Issue 9413 & Issue 9414).
Comment #1 by robert.schadek — 2024-12-13T18:43:33Z