[Issue 24415] New: only doesn't work with elements that have a copy constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 26 17:28:23 UTC 2024


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

          Issue ID: 24415
           Summary: only doesn't work with elements that have a copy
                    constructor
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: issues.dlang at jmdavisProg.com

This code

---
void main()
{
    import std.range;

    auto a = only(S.init);
    auto b = a;
}

struct S
{
    this(ref return scope inout(S) rhs) scope @safe inout pure nothrow
    {
    }
}
---

results in the error

---
q.d(6): Error: no property `__ctor` for `b` of type `std.range.OnlyResult!(S)`
/usr/local/include/dmd/std/range/package.d(10333):        struct `OnlyResult`
defined here
---

The error seems to stem from the fact that OnlyResult declares a copy
constructor but then makes it private for some reason.

--


More information about the Digitalmars-d-bugs mailing list