www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22901] New: Can't construct inout SumType

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

          Issue ID: 22901
           Summary: Can't construct inout SumType
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

As of DMD 2.099.0, the following program fails to compile:

---
import std.sumtype;

inout(SumType!(int[])) example(inout int[] arr)
{
    return inout(SumType!(int[]))(arr);
}
---

The error message is:

---
onlineapp.d(5): Error: none of the overloads of `__ctor` are callable using a
`inout` object
/dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(366):        Candidates
are: `std.sumtype.SumType!(int[]).SumType.this(int[] value)`
/dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(388):                    
   `std.sumtype.SumType!(int[]).SumType.this(const(int[]) value)`
/dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(405):                    
   `std.sumtype.SumType!(int[]).SumType.this(immutable(int[]) value)`
---

--
Mar 18 2022