Bug 23360 – Template alias to tuple member variable doesn't expand

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-09-22T13:14:03Z
Last change time
2024-12-13T19:24:37Z
Assigned to
No Owner
Creator
Paul Backus
Moved to GitHub: dmd#20153 →

Comments

Comment #0 by snarwin+bugzilla — 2022-09-22T13:14:03Z
As of DMD 2.100.2, the following program fails to compile: --- alias AliasSeq(Args...) = Args; struct Foo { AliasSeq!(int) tuple; alias slice() = tuple; } void main() { Foo foo; AliasSeq!(int) t = foo.slice!(); } --- The error message is: --- bug.d(10): Error: cannot implicitly convert expression `foo.tuple(__tuple_field_0)` of type `(int)` to `int` --- In other words, the tuple expression on the right-hand side is not expanded, which causes a type mismatch.
Comment #1 by snarwin+bugzilla — 2022-09-22T13:20:46Z
Note that the following alternatives compile successfully: --- // OK - use foo.tuple directly AliasSeq!(int) t = foo.tuple; --- --- // OK - attach the `this` reference explicitly AliasSeq!(int) t = __traits(child, foo, Foo.slice!()); --- ...although the __traits(child) workaround fails in the general case, when the tuple has more than one element: --- alias AliasSeq(Args...) = Args; struct Foo { AliasSeq!(int, int) tuple; alias slice() = tuple; } void main() { Foo foo; AliasSeq!(int, int) t = __traits(child, foo, Foo.slice!()); // Error: expected 2 arguments for `child` but had 3 } ---
Comment #2 by robert.schadek — 2024-12-13T19:24:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20153 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB