[Issue 18606] [REG2.072] "cannot append type const(T) to type T[]" in .dup

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 11 18:12:39 UTC 2019


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

John Colvin <john.loughran.colvin at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.loughran.colvin at gmail.
                   |                            |com

--- Comment #3 from John Colvin <john.loughran.colvin at gmail.com> ---
Related:

struct S
{
    string get(string key)
    {
        return key;
    }
    alias get this;
}

void main()
{
    S[] a;
    auto b = a.dup;
}

/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4473): Error: mutable
method onlineapp.S.get is not callable using a const object
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4473):       
Consider adding const or inout to onlineapp.S.get
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4460): Error:
template instance `object._dup!(const(S), S)` error instantiating
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4424):       
instantiated from here: _trustedDup!(const(S), S)
onlineapp.d(13):        instantiated from here: dup!(S)


and


struct S
{
    string get(string key) const
    {
        return key;
    }
    alias get this;
}

void main()
{
    S[] a;
    auto b = a.dup;
}

/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4473): Error:
function onlineapp.S.get(string key) const is not callable using argument types
() const
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4473):        missing
argument for parameter #1: string key
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4460): Error:
template instance `object._dup!(const(S), S)` error instantiating
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4424):       
instantiated from here: _trustedDup!(const(S), S)
onlineapp.d(13):        instantiated from here: dup!(S)

--


More information about the Digitalmars-d-bugs mailing list