Thread overview |
---|
January 21, 2009 [Issue 2601] New: Extraneous cast introduced in member access | ||||
---|---|---|---|---|
| ||||
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@digitalmars.com ReportedBy: andrei@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. -- |
January 15, 2010 [Issue 2601] Extraneous cast introduced in member access | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2601 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-invalid-code |rejects-valid Version|2.000 |1.050 --- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-01-15 04:37:28 PST --- The segfault was fixed long ago. Reduced test case also fails on D1. I'm not certain it's a bug, though. -------- void next(ref int[] a) { a[0] = 0; } void bug2601() { int[3] b; next(b); } bug.d(5): Error: cast(int[])b is not an lvalue -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 13, 2011 [Issue 2601] Extraneous cast introduced in member access | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2601 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |FIXED --- Comment #2 from yebblies <yebblies@gmail.com> 2011-06-12 21:52:41 PDT --- I think array literals have become dynamic since then, so the case in comment 1 works. The case in comment 2 does not appear to be a bug, casting a static array to a dynamic array cannot result in an lvalue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation