D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 18606 - [REG2.072] "cannot append type const(T) to type T[]" in .dup
Summary: [REG2.072] "cannot append type const(T) to type T[]" in .dup
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-03-13 15:56 UTC by Vladimir Panteleev
Modified: 2024-12-13 18:57 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2018-03-13 15:56:49 UTC
///////// test.d /////////
struct S
{
    struct T
    {
        int foo;
        int[] bar;
    }

    struct M()
    {
        T[] arr;

        this(this)
        {
            arr = arr.dup;
        }
    }

    M!() m;
}
//////////////////////////

Introduced in https://github.com/dlang/dmd/pull/5500
Comment 1 Walter Bright 2018-05-14 13:39:43 UTC
(In reply to Vladimir Panteleev from comment #0)
> Introduced in https://github.com/dlang/dmd/pull/5500

This is why I don't like 700 line PRs spread across 18 files :-(
Comment 2 Vladimir Panteleev 2018-05-14 19:39:02 UTC
The commits are big too, but if it helped, I can bisect it down to the commit.
Comment 3 John Colvin 2019-01-11 18:12:39 UTC
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)
Comment 4 dlangBugzillaToGithub 2024-12-13 18:57:51 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19409

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB