Bug 21124 – Multiple templated is expressions used with logical operators

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2020-08-05T20:36:23Z
Last change time
2024-12-13T19:10:39Z
Assigned to
No Owner
Creator
John Hall
Moved to GitHub: dmd#19760 →

Comments

Comment #0 by john.michael.hall — 2020-08-05T20:36:23Z
The code below fails to compile because the template parameter U is in both is statements in isFoo. The code for isFoo2, which changes the U in the second is statement, compiles without error. I see nothing in the specification that would suggest that isFoo should fail to compile, though I may have missed it. Nevertheless, there is a workaround. struct Foo(T) { T x; } struct Foo(T, U) { T x; } enum bool isFoo(T) = is(T : Foo!(U), U) || is(T : Foo!(U, V), U, V); enum bool isFoo2(T) = is(T : Foo!(U), U) || is(T : Foo!(W, V), W, V); void main() { static assert(isFoo!(Foo!(int))); static assert(isFoo!(Foo!(int, int))); static assert(isFoo2!(Foo!(int))); static assert(isFoo2!(Foo!(int, int))); }
Comment #1 by robert.schadek — 2024-12-13T19:10:39Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19760 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB