D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4139 - Forward reference error in front() of iterable struct
Summary: Forward reference error in front() of iterable struct
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-01 12:20 UTC by bearophile_hugs
Modified: 2015-06-09 05:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-05-01 12:20:53 UTC
This is D2 code:


Foo!(TArray) foo(TArray)(TArray r) { // the usual helper function
    return Foo!(TArray)(r);
}
struct Foo(TArray) {
    TArray arr;
    bool empty() { return !arr.length; }
    void popFront() { arr = arr[1 .. $]; }
    // int front() { return arr[0]; } // OK
    auto front() { return arr[0]; } // line 12
}
void main() {
    foreach (el; foo([10])) {}
}


DMD 2.043 prints:
test.d(12): Error: forward reference to inferred return type of function call __r1.front()
Comment 1 bearophile_hugs 2010-08-26 07:58:48 UTC
This bug is missing in dmd 2.048, so I close it.