[dmd 2.066-b1] std.range.array with shared objects and AA rehash
NCrashed via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 7 02:53:21 PDT 2014
I am using ranges (wrapped in InputRangeObject for use in
interfaces) of shared objects, with new beta some cases are
broken:
```
import std.range;
class A {}
InputRange!(shared A) foo()
{
return [new A].inputRangeObject;
}
void bar()
{
auto res = foo.array;
}
void main() {}
```
Fails with:
```
source/app.d(7): Error: cannot implicitly convert expression
(inputRangeObject([new A])) of type
std.range.InputRangeObject!(A[]).InputRangeObject to
std.range.InputRange!(shared(A)).InputRange
/usr/include/dmd/phobos/std/conv.d(3914): Error: cannot
implicitly convert expression (arg) of type shared(A) to app.A
/usr/include/dmd/phobos/std/array.d(2476): Error: template
instance std.conv.emplaceRef!(shared(A)).emplaceRef!(shared(A))
error instantiating
/usr/include/dmd/phobos/std/array.d(64): instantiated from
here: put!(shared(A))
source/app.d(12): instantiated from here:
array!(InputRange!(shared(A)))
```
And also AA starts behave strange in shared context:
```
shared string[][string] map;
void main()
{
map.rehash;
}
```
My AA is stored in shared class, the shared is inferred
implicitly. Also following workaround works:
```
void main()
{
(cast(shared(string[])[string])map).rehash;
}
```
Is this behavior a bug, or it works as expected?
More information about the Digitalmars-d-learn
mailing list