Bug 4695 – std.range.zip is broken

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2010-08-20T15:12:00Z
Last change time
2012-04-22T03:45:36Z
Assigned to
andrei
Creator
necroment

Comments

Comment #0 by necroment — 2010-08-20T15:12:41Z
import std.range; void main() { auto a = [ 1, 2, 3 ]; immutable b = [ 1, 2, 3 ]; zip(a, b); } outputs: src/phobos/std/range.d(1732): Error: can only initialize const member _field_field_1 inside constructor import std.range; void main() { auto a = [ 1, 2, 3 ]; auto b = [ 'a', 'b', 'c' ]; zip(a, b); } outputs: src/phobos/std/range.d(1773): Error: front(this.ranges._field_field_1) is not an lvalue
Comment #1 by dsimcha — 2010-08-28T13:17:34Z
Thanks for the report. I just wanted to note that this is more of a design issue than an implementation bug. The lack of tail const makes making higher order ranges work properly for const/immutable ranges impossible except in some special cases. (const/immutable arrays are one of these special cases.) This flaw may eventually get fixed, or we may eventually special case everything to work with at least const/immutable arrays, but there are deeper issues that need to be resolved before this gets fixed.
Comment #2 by lovelydear — 2012-04-21T15:27:13Z
Works on 2.059
Comment #3 by bearophile_hugs — 2012-04-22T03:45:36Z
While the general problem is not solved, this specific problem with arrays is solved.