The following program fails to compile as of DMD 2.096.1: --- struct Outer(T) { Inner!T inner; alias inner this; } struct Inner(T) { T t; } static assert(is(Outer!int : Inner!int)); // ok static assert(is(Outer!int : Inner!T, T)); // error --- The error message is: -- bug.d(11): Error: static assert: `is(Outer!int : Inner!T, __isexp_id2, T)` is false --- The expected behavior is for both static assert statements to pass. Surprisingly, changing Inner and Outer from structs to classes causes the second static assert statement to pass: --- class Outer(T) { Inner!T inner; alias inner this; } class Inner(T) { T t; } static assert(is(Outer!int : Inner!int)); // ok static assert(is(Outer!int : Inner!T, T)); // ok ---
@pbackus created dlang/phobos pull request #8394 "sumtype: work around issue 21975 in isSumType" mentioning this issue: - sumtype: work around issue 21975 in isSumType isSumType!T now evaluates to true instead of false when T is a templated struct type that implicitly converts to a SumType via alias this. https://github.com/dlang/phobos/pull/8394
dlang/phobos pull request #8394 "sumtype: work around issue 21975 in isSumType" was merged into master: - c47c861646ddbb8bd30be849aee37a6167ab41f3 by Paul Backus: sumtype: work around issue 21975 in isSumType isSumType!T now evaluates to true instead of false when T is a templated struct type that implicitly converts to a SumType via alias this. https://github.com/dlang/phobos/pull/8394
@RazvanN7 created dlang/dmd pull request #13738 "Fix Issue 21975 - is expression ignores implicit conversion of struct via alias this when pattern matching" fixing this issue: - Fix Issue 21975 - is expression ignores implicit conversion of struct via alias this when pattern matching https://github.com/dlang/dmd/pull/13738
dlang/dmd pull request #13738 "Fix Issue 21975 - is expression ignores implicit conversion of struct via alias this when pattern matching" was merged into master: - 7e62db470b9e73bb6d9813e25295d9277f313131 by RazvanN7: Fix Issue 21975 - is expression ignores implicit conversion of struct via alias this when pattern matching https://github.com/dlang/dmd/pull/13738
dlang/phobos pull request #8397 "Revert "sumtype: work around issue 21975 in isSumType"" was merged into master: - 7806947d9447f12062ac0976f9918bec79398449 by Paul Backus: Revert "sumtype: work around issue 21975 in isSumType" This reverts commit 2de68340ae2a057fd993af7bc2388325e68a9186. https://github.com/dlang/phobos/pull/8397