[Issue 17272] New: std.experimental.typecons.Final inconsistent behaviour with built-in arrays

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Mar 23 17:00:13 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17272

          Issue ID: 17272
           Summary: std.experimental.typecons.Final inconsistent behaviour
                    with built-in arrays
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: hsteoh at quickfur.ath.cx

Code:
-----
import std.experimental.typecons;
void main()
{
    Final!(int[]) s;    // s is a head const array...
    s.length = 5;       // look, ma! I modified the array!
    assert(s.length == 5); // passes

    //s.ptr = null;     // does not compile
}
-----

Firstly, it's questionable whether modifying array length should be allowed
under Final.

But secondly, if we're allowed to modify s.length then it's inconsistent to
reject modifying s.ptr.

--


More information about the Digitalmars-d-bugs mailing list