Skip to content

Commit

Permalink
Merge pull request #2338 from 9rnsr/fix13077
Browse files Browse the repository at this point in the history
[REG2.066a] Issue 13077 - std.range.array with shared InputRangeObject
Conflicts:
	std/array.d
  • Loading branch information
yebblies authored and 9rnsr committed Jul 17, 2014
1 parent 23d9989 commit e511efd
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions std/array.d
Expand Up @@ -2473,7 +2473,12 @@ struct Appender(A : T[], T)
auto bigDataFun() @trusted nothrow { return _data.arr.ptr[0 .. len + 1];}
auto bigData = bigDataFun();

emplaceRef!T(bigData[len], item);
static if (is(Unqual!T == T))
alias uitem = item;
else
auto ref uitem() @trusted nothrow @property { return cast(Unqual!T)item; }

emplaceRef!(Unqual!T)(bigData[len], uitem);

//We do this at the end, in case of exceptions
_data.arr = bigData;
Expand Down Expand Up @@ -2939,7 +2944,8 @@ unittest
}

unittest
{ //9528
{
//9528
const(E)[] fastCopy(E)(E[] src) {
auto app = appender!(const(E)[])();
foreach (i, e; src)
Expand All @@ -2955,15 +2961,16 @@ unittest
}

unittest
{ //10753
{
//10753
struct Foo {
immutable dchar d;
}
struct Bar {
immutable int x;
}
"12".map!Foo.array;
[1, 2].map!Bar.array;
"12".map!Foo.array;
[1, 2].map!Bar.array;
}

unittest
Expand Down Expand Up @@ -3027,6 +3034,24 @@ unittest // check against .clear UFCS hijacking
"Remove me when object.clear is removed!");
}

unittest
{
// Issue 13077
static class A {}

// reduced case
auto w = appender!(shared(A)[])();
w.put(new shared A());

// original case
import std.range;
InputRange!(shared A) foo()
{
return [new shared A].inputRangeObject;
}
auto res = foo.array;
}

/++
Convenience function that returns a $(D RefAppender!A) object initialized
with $(D array). Don't use null for the $(D array) pointer, use the other
Expand Down

0 comments on commit e511efd

Please sign in to comment.