← Back to index
|
Original Bugzilla link
Bug 23687 – IFTI fails forwarding an alias to struct field
Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2023-02-12T02:53:13Z
Last change time
2024-12-13T19:27:15Z
Assigned to
No Owner
Creator
Ben
Moved to GitHub: dmd#20230 →
Comments
Comment #0
by ben.james.jones — 2023-02-12T02:53:13Z
``` import std.stdio; import std.range; struct LinkedListAdaptor(alias nextField, T){ T current; @safe: nothrow: this(T head){ current = head; } bool empty() const { return current == null; } T front() { return current; } void popFront() { current = __traits(child, current, nextField); } } auto linkedListAdaptor(alias nextField, T)(T head) if(is(T == U*, U)){ return LinkedListAdaptor!(nextField, T)(head); //fails with: //onlineapp.d(27): Error: symbol or expression expected as first argument of __traits `child` instead of `Node*` // return LinkedListAdaptor!(__traits(child, T, nextField), T)(head); } struct Node{ int data; Node* next; } void main(){ Node* head = new Node(10, new Node(20, null)); auto rng1 = LinkedListAdaptor!(Node.next, Node*)(head); //OK auto rng = linkedListAdaptor!(Node.next)(head); foreach(const x; rng){ writeln(x.data); } } ``` fails on the `auto rng = linkedListAdaptor!(Node.next)(head);` line with `Error: need `this` for `linkedListAdaptor` of type `pure nothrow @nogc @safe LinkedListAdaptor!(next, Node*)(Node* head)``
Comment #1
by robert.schadek — 2024-12-13T19:27:15Z
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/dmd/issues/20230
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB