Bug 23174 – Can't alias tuple when it's part of dot expression following a struct literal

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-06-09T08:31:10Z
Last change time
2022-06-09T10:13:49Z
Keywords
pull
Assigned to
No Owner
Creator
Boris Carvajal

Comments

Comment #0 by boris2.9 — 2022-06-09T08:31:10Z
Reported on the forum by Jacob Carlborg in 2016 https://forum.dlang.org/post/[email protected] import std.meta; struct Fields(T) { private static alias toField(alias e) = Field!(__traits(identifier, e)); alias fields = staticMap!(toField, T.tupleof); static alias map(alias F) = staticMap!(F, fields); static alias filter(alias pred) = Filter!(pred, fields); } struct Field(string n) { enum name = n; } struct Foo { int a; } void main() { Foo value; enum toName(alias e) = e.name; enum pred(alias e) = true; alias a = Fields!(Foo).filter!(pred); // works alias b = Fields!(Foo).map!(toName); // works alias c = Fields!(Foo).init.filter!(pred); // works alias d = Fields!(Foo).init.map!(toName); // Error: alias d cannot alias an expression Fields().tuple("a") }
Comment #1 by dlang-bot — 2022-06-09T08:50:27Z
@BorisCarvajal created dlang/dmd pull request #14196 "Fix Issue 23174 - Can't alias tuple when it's part of dot expression following a struct literal" fixing this issue: - Fix Issue 23174 - Can't alias tuple when it's part of dot expression following a struct literal https://github.com/dlang/dmd/pull/14196
Comment #2 by dlang-bot — 2022-06-09T10:13:49Z
dlang/dmd pull request #14196 "Fix Issue 23174 - Can't alias tuple when it's part of dot expression following a struct literal" was merged into master: - ee0bf6911a45f4eef9d6edea2a0070fbb030d2d5 by Boris Carvajal: Fix Issue 23174 - Can't alias tuple when it's part of dot expression following a struct literal https://github.com/dlang/dmd/pull/14196