https://issues.dlang.org/show_bug.cgi?id=22572
Paul Backus <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Paul Backus <[email protected]> --- There's definitely a SumType issue here: --- import std.sumtype; struct CopyConstruct { this(ref inout CopyConstruct other) inout { } } immutable struct Value { CopyConstruct c; } alias _ = SumType!Value; --- The example above produces the following error message, as of DMD/Phobos 2.098.1: --- /dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(1998): Error: static assert: "`handlers[0]` of type `template` never matches" /dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(1590): instantiated from here: `matchImpl!(inout(SumType!(immutable(Value))))` /dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(452): instantiated from here: `match!(inout(SumType!(immutable(Value))))` onlineapp.d(13): instantiated from here: `SumType!(immutable(Value))` --- The source of the error is this line: https://github.com/dlang/phobos/blob/v2.098.1/std/sumtype.d#L452 Compiling with -verrors=spec reveals the following gagged error, which is ultimately responsible for the failure: --- (spec:1) src/sumtype.d(389): Error: `inout` on `return` means `inout` must be on a parameter as well for `pure nothrow @nogc @safe inout(Storage)(ref immutable(Value) value)` --- SumType's copy constructor incorrectly assumes that, when copying from an `inout(SumType) other`, the value stored in `other` will also be inout-qualified. However, this is not the case when one of other's members is an immutable struct, because the qualifier combination `immutable inout` collapses to just `immutable`. --
