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

Paul Backus <snarwin+bugzi...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzi...@gmail.com
          Component|phobos                      |dmd
           Hardware|x86_64                      |All
            Summary|only doesn't work with      |Can't call public copy
                   |elements that have a copy   |constructor preceded by
                   |constructor                 |private template
                   |                            |constructor

--- Comment #2 from Paul Backus <snarwin+bugzi...@gmail.com> ---
This is a compiler bug. The presence of a private templated constructor earlier
in the overload set prevents the public copy constructor from being called from
another module.

Minimal reproduction:

--- lib.d
module lib;

struct S
{
    int n;
    private this()(int n) { this.n = m; }
    this(ref inout S other) inout {}
}
--- app.d
module app;

import lib;

void main()
{
    S a;
    auto b = a;
}
---

Which produces this error message when compiled:

---
app.d(8): Error: no property `__ctor` for `b` of type `lib.S`
lib.d(3):        struct `S` defined here
---

Note that the bug is order-dependent. If the copy constructor is moved above
the private templated constructor, the example compiles successfully.

--

Reply via email to