Comment #0 by snarwin+bugzilla — 2022-03-18T18:54:27Z
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)`
---
Comment #1 by dlang-bot — 2022-03-20T19:11:40Z
@pbackus created dlang/phobos pull request #8413 "Fix issue 22901 - Can't construct inout SumType" fixing this issue:
- Fix issue 22901 - Can't construct inout SumType
The template constraint is needed to ensure that the inout constructor
overload is only considered when it is an exact match, without qualifier
conversions.
Without the constraint, a constructor call such as
const(SumType!(int[]))([1, 2, 3])
...would be ambiguous, since it would match both the const constructor
overload and the inout constructor overload at the "match with qualifier
conversion" level.
https://github.com/dlang/phobos/pull/8413
Comment #2 by dlang-bot — 2022-03-21T12:37:04Z
dlang/phobos pull request #8413 "Fix issue 22901 - Can't construct inout SumType" was merged into master:
- d9d104c9bc64540c3ab87cc15665aeb9d0d11e4e by Paul Backus:
Fix issue 22901 - Can't construct inout SumType
The template constraint is needed to ensure that the inout constructor
overload is only considered when it is an exact match, without qualifier
conversions.
Without the constraint, a constructor call such as
const(SumType!(int[]))([1, 2, 3])
...would be ambiguous, since it would match both the const constructor
overload and the inout constructor overload at the "match with qualifier
conversion" level.
https://github.com/dlang/phobos/pull/8413