Skip to content

Commit 54eb95c

Browse files
authored
Merge pull request #8988 from ibuclaw/merge_stable
merge stable
2 parents 4b2ea30 + 688816e commit 54eb95c

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

.dscanner.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ comma_expression_check="enabled"
5252
; Checks for local imports that are too broad
5353
local_import_check="skip-unittest"
5454
; Checks for variables that could be declared immutable
55-
could_be_immutable_check="enabled"
55+
could_be_immutable_check="skip-unittest"
5656
; Checks for redundant expressions in if statements
5757
redundant_if_check="enabled"
5858
; Checks for redundant parenthesis

std/internal/test/range.d

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,94 @@ module std.internal.test.range;
2323
auto r = R().chunks(3);
2424
assert(r.equal!equal([[ 0, 1, 2 ], [ 3, 4 ]]));
2525
}
26+
27+
// https://issues.dlang.org/show_bug.cgi?id=24415
28+
@safe unittest
29+
{
30+
import std.range : only;
31+
32+
static struct S(T)
33+
{
34+
T i;
35+
36+
this(ref return scope inout(S) rhs) scope @safe inout pure nothrow
37+
{
38+
i = rhs.i;
39+
}
40+
}
41+
{
42+
auto a = only(S!int(42));
43+
auto b = a;
44+
assert(!b.empty);
45+
assert(b.front == S!int(42));
46+
47+
a.popFront();
48+
auto c = a;
49+
assert(c.empty);
50+
}
51+
{
52+
auto a = only(S!(const int)(42));
53+
auto b = a;
54+
assert(!b.empty);
55+
assert(b.front == S!(const int)(42));
56+
57+
a.popFront();
58+
auto c = a;
59+
assert(c.empty);
60+
}
61+
{
62+
auto a = only(S!(immutable int)(42));
63+
auto b = a;
64+
assert(!b.empty);
65+
assert(b.front == S!(immutable int)(42));
66+
67+
a.popFront();
68+
auto c = a;
69+
assert(c.empty);
70+
}
71+
{
72+
auto a = only(S!int(42), S!int(192));
73+
auto b = a;
74+
assert(!b.empty);
75+
assert(b.front == S!int(42));
76+
77+
a.popFront();
78+
auto c = a;
79+
assert(!c.empty);
80+
assert(c.front == S!int(192));
81+
82+
a.popFront();
83+
auto d = a;
84+
assert(d.empty);
85+
}
86+
{
87+
auto a = only(S!(const int)(42), S!(const int)(192));
88+
auto b = a;
89+
assert(!b.empty);
90+
assert(b.front == S!(const int)(42));
91+
92+
a.popFront();
93+
auto c = a;
94+
assert(!c.empty);
95+
assert(c.front == S!(const int)(192));
96+
97+
a.popFront();
98+
auto d = a;
99+
assert(d.empty);
100+
}
101+
{
102+
auto a = only(S!(immutable int)(42), S!(immutable int)(192));
103+
auto b = a;
104+
assert(!b.empty);
105+
assert(b.front == S!(immutable int)(42));
106+
107+
a.popFront();
108+
auto c = a;
109+
assert(!c.empty);
110+
assert(c.front == S!(immutable int)(192));
111+
112+
a.popFront();
113+
auto d = a;
114+
assert(d.empty);
115+
}
116+
}

std/range/package.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10398,6 +10398,14 @@ private struct OnlyResult(T)
1039810398
}
1039910399
alias opDollar = length;
1040010400

10401+
// FIXME Workaround for https://issues.dlang.org/show_bug.cgi?id=24415
10402+
import std.traits : hasElaborateCopyConstructor;
10403+
static if (hasElaborateCopyConstructor!T)
10404+
{
10405+
private static struct WorkaroundBugzilla24415 {}
10406+
public this()(WorkaroundBugzilla24415) {}
10407+
}
10408+
1040110409
private this()(return scope auto ref T value)
1040210410
{
1040310411
ref @trusted unqual(ref T x){return cast() x;}

0 commit comments

Comments
 (0)