digitalmars.D.bugs - [Issue 24565] New: out contract variable is implicitly const
- d-bugmail puremagic.com (29/29) May 24 https://issues.dlang.org/show_bug.cgi?id=24565
https://issues.dlang.org/show_bug.cgi?id=24565 Issue ID: 24565 Summary: out contract variable is implicitly const Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: minor Priority: P1 Component: dlang.org Assignee: nobody puremagic.com Reporter: nick geany.org The spec does not mention this: https://dlang.org/spec/function.html#postconditions struct R { bool empty(); // only logically const, not D const } R f() // returns a mutable R out(r; r.empty) // Error: mutable method `R.empty` is not callable using a `const` object { R r; // not const return r; } For the above case, an `out` contract cannot be used. Note that inserting `assert(r.empty);` before the return statement does work. --
May 24