-
Notifications
You must be signed in to change notification settings - Fork 0
/
scope.d
116 lines (86 loc) · 1.59 KB
/
scope.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
REQUIRED_ARGS: -preview=dip1000
*/
struct Cache
{
ubyte[1] v;
ubyte[] set(ubyte[1] v) return
{
return this.v[] = v[];
}
}
/*********************************/
// https://github.com/dlang/dmd/pull/9220
@safe:
struct OnlyResult
{
private this(Values)(scope ref Values values)
{
this.s = values;
}
string s;
}
auto only(Values)(Values vv)
{
return OnlyResult(vv);
}
void test() @nogc @safe pure
{
only(null);
}
/************************************/
// https://github.com/dlang/dmd/pull/9220
auto callWrappedOops(scope string dArgs) {
string callWrappedImpl() {
return dArgs;
}
}
/************************************/
struct Constant
{
int* member;
this(Repeat!(int*) grid) @safe
{
foreach(ref x; grid)
member = x;
foreach(ref x; grid)
x = member;
}
int* foo(return scope Repeat!(int*) grid) @safe
{
foreach(ref x; grid)
x = member;
foreach(ref x; grid)
return x;
return null;
}
alias Repeat(T...) = T;
}
/************************************/
// https://issues.dlang.org/show_bug.cgi?id=20675
struct D
{
int pos;
char* p;
}
void test(scope ref D d) @safe
{
D[] da;
da ~= D(d.pos, null);
}
// https://issues.dlang.org/show_bug.cgi?id=20682
int f1_20682(return scope ref D d) @safe
{
return d.pos;
}
ref int f2_20682(return scope ref D d) @safe
{
return d.pos;
}
void test_20682(scope ref D d) @safe
{
int[] a;
a ~= f1_20682(d);
a ~= f2_20682(d);
a ~= cast(int) d.p;
}