[Issue 21975] New: is expression ignores implicit conversion of struct via alias this when pattern matching
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 25 17:47:13 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21975
Issue ID: 21975
Summary: is expression ignores implicit conversion of struct
via alias this when pattern matching
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: snarwin+bugzilla at gmail.com
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
---
--
More information about the Digitalmars-d-bugs
mailing list