[Issue 2601] New: Extraneous cast introduced in member access
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 21 09:50:18 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2601
Summary: Extraneous cast introduced in member access
Product: D
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: andrei at metalanguage.com
I could probably simplify this a bit more, but it's short enough:
import std.functional;
void next(T)(ref T[] a) { assert(a.length); a = a[1 .. $]; }
struct MapRange(alias funAlias, Range)
{
Range _input;
void next() { _input.next; }
}
template map(fun...)
{
alias mapImpl!(fun).result map;
}
template mapImpl(alias fun)
{
MapRange!(fun, Range) result(Range)(Range input)
{
return typeof(return)(input);
}
}
unittest
{
auto x = map!("2 * a")([1, 2, 3, 4, 5]);
//auto y = mapImpl!(fun).result!("2 * a")([1, 2, 3, 4, 5]);
}
The code fails to compile with:
Error: cast(int[])this._input is not an lvalue
As a bonus, uncommenting the last (albeit incorrect) line in unittest crashes
dmd.
--
More information about the Digitalmars-d-bugs
mailing list