Bug 7258 – std.array.array of const items

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-01-09T12:46:00Z
Last change time
2013-02-09T21:51:07Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-01-09T12:46:15Z
I think std.array.array shoult support code like this too, if possible: import std.algorithm: map; import std.array: array; void main() { auto r = map!(a => cast(const int)a)([1, 2]); array(r); } DMD 2.058 Head: ...\dmd2\src\phobos\std\array.d(55): Error: result[i] isn't mutable test.d(5): Error: template instance std.array.array!(Result) error instantiating
Comment #1 by bearophile_hugs — 2012-01-30T17:12:30Z
Simpler test case: import std.array: array; void main() { const(int)[] A = [1, 2]; array(A); } DMD 2.058head: ...\dmd2\src\phobos\std\array.d(55): Error: result[i] isn't mutable test.d(4): Error: template instance std.array.array!(const(int)[]) error instantiating I have also renamed this bug report.
Comment #2 by bearophile_hugs — 2012-04-19T15:24:38Z
This is borderline between a bug and an enhancement request.
Comment #3 by yebblies — 2012-07-10T07:51:27Z
I suspect the reason std.array.array does not handle this case is due to an oversight and is not part of the design, and this is therefore a bug.
Comment #4 by andrej.mitrovich — 2013-02-09T21:51:07Z
Both cases fixed in 2.060.