/
failob2.d
67 lines (56 loc) · 1.62 KB
/
failob2.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
// REQUIRED_ARGS: -preview=dip1021
/*
TEST_OUTPUT:
---
fail_compilation/failob2.d(105): Error: variable `failob2.foo1!int.foo1.p` has undefined state and cannot be read
fail_compilation/failob2.d(105): Error: variable `failob2.foo1!int.foo1.p` is returned but is Undefined
fail_compilation/failob2.d(124): Error: template instance `failob2.foo1!int` error instantiating
fail_compilation/failob2.d(111): Error: variable `failob2.foo2!int.foo2.p` has undefined state and cannot be read
fail_compilation/failob2.d(111): Error: variable `failob2.foo2!int.foo2.p` is returned but is Undefined
fail_compilation/failob2.d(125): Error: template instance `failob2.foo2!int` error instantiating
fail_compilation/failob2.d(119): Error: variable `failob2.foo3!int.foo3.p` has undefined state and cannot be read
fail_compilation/failob2.d(119): Error: variable `failob2.foo3!int.foo3.p` is returned but is Undefined
fail_compilation/failob2.d(126): Error: template instance `failob2.foo3!int` error instantiating
---
*/
#line 100
@live
T* foo1(T)()
{
T* p = void;
return p;
}
template foo2(T) {
@live T* foo2() {
T* p = void;
return p;
}
}
@live
template foo3(T) {
T* foo3() {
T* p = void;
return p;
}
}
void test1() {
foo1!int();
foo2!int();
foo3!int();
}
/*
TEST_OUTPUT:
---
fail_compilation/failob2.d(205): Error: variable `failob2.foo4!int.foo4.p` is left dangling at return
fail_compilation/failob2.d(209): Error: template instance `failob2.foo4!int` error instantiating
---
*/
#line 200
void* alloc(size_t);
@live void foo4(T)()
{
auto p = alloc(4);
}
void test2() {
foo4!int();
}