www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17272] New: std.experimental.typecons.Final inconsistent

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 puremagic.com
          Reporter: hsteoh 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.

--
Mar 23 2017