[Issue 12512] .dup of const structs does not work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 13 10:26:42 PDT 2014


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

monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #6 from monarchdodra at gmail.com ---
(In reply to Walter Bright from comment #5)
> The s.dup should work. Marking this as a bug, not an enhancement.

It's NOT a bug!

> Note that:
> 
>     const(int*)[] s;
>     s.dup;
> 
> does work.

That's *still* a type where "const(T) : T": "Unqual!(const(int*))" is
"const(int)*".

dup simply *can't* work for certain types. For example, something as trivial as
classes:

//----
class A{}

void main()
{
    const(A)[] a;
    a.dup;
}
//----
Error: cannot implicitly convert element type const(A) to mutable in a.dup
//----

> Not going to do a .cdup

Fine. Could we then allow "dup" to return "const(T)[]" for the cases where it
can't return a mutable then?

--


More information about the Digitalmars-d-bugs mailing list