Bug 14930 – Unable to array() a const map() result

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-18T12:19:47Z
Last change time
2018-02-09T12:09:46Z
Assigned to
No Owner
Creator
Infiltrator

Comments

Comment #0 by lt.infiltrator — 2015-08-18T12:19:47Z
import std.algorithm; import std.array; class S { } class T { @property bar() inout { return _bar; } S _bar; } string fun() { auto ts = [new const T]; ts.map!(t => t.bar).array; } ---------------------------- /usr/include/d/4.9/std/conv.d:3914: error: static assert "S cannot be emplaced from a const(S)." /usr/include/d/4.9/std/array.d:49: note: instantiated from here: emplace!(S, const(S)) src/array.d:13: note: instantiated from here: array!(MapResult!(__lambda1, const(T)[]))
Comment #1 by lt.infiltrator — 2015-08-18T12:22:02Z
I've been advised that this works with 2.068. I'll go and upgrade now. Sorry for the noise.
Comment #2 by lt.infiltrator — 2015-08-18T12:30:55Z
Scratch that last comment. I misunderstood.
Comment #3 by johannes.loher — 2017-08-14T10:30:58Z
Aside from the fact, that fun() does not return a string, this seems to work. Any reasons not to close this?
Comment #4 by greensunny12 — 2018-02-09T12:09:46Z
Works for me too. Please reopen if the bug still exists.