Thread overview
[Issue 24415] Can't call public function preceded by private template overload
[Issue 24415] only doesn't work with elements that have a copy constructor
Feb 26
Dlang Bot
[Issue 24415] Can't call public copy constructor preceded by private template constructor
[Issue 24415] Can't call public constructor preceded by private template constructor
Feb 26
basile-z
Apr 09
Dlang Bot
Apr 25
Dlang Bot
Apr 26
Dlang Bot
February 26
https://issues.dlang.org/show_bug.cgi?id=24415

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> ---
@jmdavis created dlang/phobos pull request #8924 "Fix bugzilla issue 24415 - only doesn't work with elements with a copy constructor." fixing this issue:

- Fix bugzilla issue 24415 - only doesn't work with elements with a copy constructor.

  I have no clue why anyone would have made a copy constructor private,
  but making the copy constructor private on OnlyResult makes it useless
  for anything outside of std.range.package, making only useless with
  elements that have a copy constructor.

  So, this commit makes it so that the copy constructor is no longer
  private.

https://github.com/dlang/phobos/pull/8924

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@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+bugzilla@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.

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Can't call public copy      |Can't call public
                   |constructor preceded by     |constructor preceded by
                   |private template            |private template
                   |constructor                 |constructor

--- Comment #3 from Paul Backus <snarwin+bugzilla@gmail.com> ---
In fact, the public constructor doesn't have to be a copy constructor to trigger the bug. Any kind of constructor will do.

--- lib.d
module lib;

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

import lib;

void main()
{
    S a = "hello"; // Error
}
---

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

basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #4 from basile-z <b2.temp@gmx.com> ---
To fo further, isn't this the bug of having overload sets made of members with different visibility ?

E.g not at all related to constructors ;)

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

--- Comment #5 from Paul Backus <snarwin+bugzilla@gmail.com> ---
Yeah, good catch. Here's the new minimal example:

--- lib.d
module lib;

private void fun()(int n) {}
void fun(string s) {}
--- app.d
module app;

import lib;

void main()
{
    fun("a");
}
---

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Can't call public           |Can't call public function
                   |constructor preceded by     |preceded by private
                   |private template            |template overload
                   |constructor                 |

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

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #8924 "Work around bugzilla issue 24415 - only doesn't work with elements with a copy constructor." was merged into stable:

- 66bbf4dae038879d1ff66af3b7ab25ea66c8320d by Jonathan M Davis:
  Work around bugzilla issue 24415 - only doesn't work with elements with a
copy constructor.

  Since the compiler is treating the auto-generated copy-constructor for
  OnlyResult as private (thus rendering it useless outside of
  std.range.package), this commit adds an explicit one and makes it
  public. Once the dmd bug has been fixed, the explicit copy constructor
  should be removed.

https://github.com/dlang/phobos/pull/8924

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

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ibuclaw created dlang/phobos pull request #8988 "merge stable" mentioning this issue:

- Work around bugzilla issue 24415 - only doesn't work with elements with a copy constructor.

  Since the compiler is treating the auto-generated copy-constructor for
  OnlyResult as private (thus rendering it useless outside of
  std.range.package), this commit adds an explicit one and makes it
  public. Once the dmd bug has been fixed, the explicit copy constructor
  should be removed.

https://github.com/dlang/phobos/pull/8988

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

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #8988 "merge stable" was merged into master:

- 34ff27e58d83e7a6135af56af2eb34ba3a6d7252 by Jonathan M Davis:
  Work around bugzilla issue 24415 - only doesn't work with elements with a
copy constructor.

  Since the compiler is treating the auto-generated copy-constructor for
  OnlyResult as private (thus rendering it useless outside of
  std.range.package), this commit adds an explicit one and makes it
  public. Once the dmd bug has been fixed, the explicit copy constructor
  should be removed.

https://github.com/dlang/phobos/pull/8988

--