On Tuesday, 9 November 2021 at 16:37:37 UTC, Timon Gehr wrote:>
On 08.11.21 15:04, Atila Neves wrote:>
On Friday, 5 November 2021 at 21:22:12 UTC, victoroak wrote:>
Interesting. Adding an invariant causes compilation to fail:
foo.d(27): Error: variable `foo.main.x` `void` initializers for structs with invariants are not allowed in safe functions
Well, that makes some sense, but a struct can have an invariant without actually having it spelled out explicitly in the source code. Furthermore, adding contracts actually makes code less safe in -release mode.
IMHO -release mode really shouldn't be used, but since contracts are supposed to prevent bugs from occurring, hopefully testing "proved" that "none" exist.
In this case specifically, even with -release one gets a compiler error, which is enough of a reason to add one methinks.