[Issue 12901] `in`/`out` contracts on struct constructor must require function body
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 28 23:31:31 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=12901
--- Comment #4 from hsteoh at quickfur.ath.cx ---
Arguably, the original fix was invalid: it doesn't stop you from writing:
````
struct S
{
int a;
this(int n) in { a = n; } body {} // or do {}
}
````
The problem really is allowing assignment to struct members from inside a
contract, which is abuse of the contract feature. Perhaps the solution should
be to enforce purity on the contract, or, less intrusively, make the contract
body const (i.e., `this` is const inside the contract body).
--
More information about the Digitalmars-d-bugs
mailing list