www.digitalmars.com         C & C++   DMDScript  

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


          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)`
   `std.sumtype.SumType!(int[]).SumType.this(const(int[]) value)`
   `std.sumtype.SumType!(int[]).SumType.this(immutable(int[]) value)`

Mar 18 2022