Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 35cd635

Browse files
authored
Merge pull request #1637 from WalterBright/scope-dup
add 'scope' to object.dup()
2 parents aee373f + 59963cc commit 35cd635

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/object.d

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,7 +3294,7 @@ unittest
32943294
}
32953295

32963296
/// Provide the .dup array property.
3297-
@property auto dup(T)(T[] a)
3297+
@property auto dup(T)(scope T[] a)
32983298
if (!is(const(T) : T))
32993299
{
33003300
import core.internal.traits : Unconst;
@@ -3310,7 +3310,7 @@ unittest
33103310

33113311
/// ditto
33123312
// const overload to support implicit conversion to immutable (unique result, see DIP29)
3313-
@property T[] dup(T)(const(T)[] a)
3313+
@property T[] dup(T)(scope const(T)[] a)
33143314
if (is(const(T) : T))
33153315
{
33163316
// wrap unsafe _dup in @trusted to preserve @safe postblit
@@ -3321,14 +3321,14 @@ unittest
33213321
}
33223322

33233323
/// ditto
3324-
@property T[] dup(T:void)(const(T)[] a) @trusted
3324+
@property T[] dup(T:void)(scope const(T)[] a) @trusted
33253325
{
33263326
if (__ctfe) assert(0, "Cannot dup a void[] array at compile time.");
33273327
return cast(T[])_rawDup(a);
33283328
}
33293329

33303330
/// Provide the .idup array property.
3331-
@property immutable(T)[] idup(T)(T[] a)
3331+
@property immutable(T)[] idup(T)(scope T[] a)
33323332
{
33333333
static assert(is(T : immutable(T)), "Cannot implicitly convert type "~T.stringof~
33343334
" to immutable in idup.");
@@ -3341,17 +3341,17 @@ unittest
33413341
}
33423342

33433343
/// ditto
3344-
@property immutable(T)[] idup(T:void)(const(T)[] a)
3344+
@property immutable(T)[] idup(T:void)(scope const(T)[] a)
33453345
{
33463346
return a.dup;
33473347
}
33483348

3349-
private U[] _trustedDup(T, U)(T[] a) @trusted
3349+
private U[] _trustedDup(T, U)(scope T[] a) @trusted
33503350
{
33513351
return _dup!(T, U)(a);
33523352
}
33533353

3354-
private U[] _dup(T, U)(T[] a) // pure nothrow depends on postblit
3354+
private U[] _dup(T, U)(scope T[] a) // pure nothrow depends on postblit
33553355
{
33563356
if (__ctfe)
33573357
{
@@ -3369,7 +3369,7 @@ private U[] _dup(T, U)(T[] a) // pure nothrow depends on postblit
33693369

33703370
private extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow;
33713371

3372-
private inout(T)[] _rawDup(T)(inout(T)[] a)
3372+
private inout(T)[] _rawDup(T)(scope inout(T)[] a)
33733373
{
33743374
import core.stdc.string : memcpy;
33753375

0 commit comments

Comments
 (0)