Bug or feature?

Jack Applegame via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 28 04:37:59 PDT 2015


I don't see any reason why it should not compile.

import std.array;
import std.range;
import std.algorithm;

class Foo {
}

void main() {
	auto result = iota(3).map!(i => new immutable Foo).array();
}

/usr/include/dmd/phobos/std/conv.d(4028): Error: cannot 
implicitly convert expression (arg) of type immutable(Foo) to 
test.Foo
/usr/include/dmd/phobos/std/conv.d(3931): Error: template 
instance 
std.conv.emplaceImpl!(immutable(Foo)).emplaceImpl!(immutable(Foo)) error instantiating
/usr/include/dmd/phobos/std/array.d(115):        instantiated 
from here: emplaceRef!(immutable(Foo), Foo, immutable(Foo))
test.d(9):        instantiated from here: 
array!(MapResult!(__lambda1, Result))


More information about the Digitalmars-d-learn mailing list