]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/fail17955.d
d: Merge upstream dmd, druntime 4574d1728d, phobos d7e79f024.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail17955.d
1 // https://issues.dlang.org/show_bug.cgi?id=17955
2 /*
3 TEST_OUTPUT:
4 ---
5 fail_compilation/fail17955.d(82): Error: cannot create instance of abstract class `SimpleTimeZone`
6 fail_compilation/fail17955.d(76): class `SimpleTimeZone` is declared here
7 fail_compilation/fail17955.d(73): function `bool hasDST()` is not implemented
8 fail_compilation/fail17955.d(94): Error: template instance `fail17955.SimpleTimeZone.fromISOExtString!dstring` error instantiating
9 fail_compilation/fail17955.d(26): instantiated from here: `fromISOExtString!string`
10 fail_compilation/fail17955.d(57): instantiated from here: `isISOExtStringSerializable!(SysTime)`
11 fail_compilation/fail17955.d(50): instantiated from here: `toRedis!(SysTime)`
12 fail_compilation/fail17955.d(41): ... (2 instantiations, -v to show) ...
13 fail_compilation/fail17955.d(33): instantiated from here: `indicesOf!(isRedisType, resetCodeExpireTime)`
14 fail_compilation/fail17955.d(68): instantiated from here: `RedisStripped!(User, true)`
15 fail_compilation/fail17955.d(94): Error: calling non-static function `fromISOExtString` requires an instance of type `SimpleTimeZone`
16 fail_compilation/fail17955.d(96): Error: undefined identifier `DateTimeException`
17 fail_compilation/fail17955.d(26): Error: variable `fail17955.isISOExtStringSerializable!(SysTime).isISOExtStringSerializable` - type `void` is inferred from initializer `fromISOExtString("")`, and variables cannot be of type `void`
18 fail_compilation/fail17955.d(55): Error: function `fail17955.toRedis!(SysTime).toRedis` has no `return` statement, but is expected to return a value of type `string`
19 ---
20 */
21
22 alias Alias(alias a) = a;
23
24 template isISOExtStringSerializable(T)
25 {
26 enum isISOExtStringSerializable = T.fromISOExtString("");
27 }
28
29 template RedisObjectCollection(){}
30
31 struct RedisStripped(T, bool strip_id = true)
32 {
33 alias unstrippedMemberIndices = indicesOf!(Select!(strip_id,
34 isRedisTypeAndNotID, isRedisType), T.tupleof);
35 }
36
37 template indicesOf(alias PRED, T...)
38 {
39 template impl(size_t i)
40 {
41 static if (PRED!T)
42 impl TypeTuple;
43 }
44
45 alias indicesOf = impl!0;
46 }
47
48 template isRedisType(alias F)
49 {
50 enum isRedisType = toRedis!(typeof(F));
51 }
52
53 template isRedisTypeAndNotID(){}
54
55 string toRedis(T)()
56 {
57 static if (isISOExtStringSerializable!T)
58 return;
59 }
60
61 struct User
62 {
63 SysTime resetCodeExpireTime;
64 }
65
66 class RedisUserManController
67 {
68 RedisObjectCollection!(RedisStripped!User) m_users;
69 }
70
71 class TimeZone
72 {
73 abstract bool hasDST();
74 }
75
76 class SimpleTimeZone : TimeZone
77 {
78 unittest {}
79
80 immutable(SimpleTimeZone) fromISOExtString(S)(S)
81 {
82 new SimpleTimeZone;
83 }
84 }
85
86 struct SysTime
87 {
88
89 static fromISOExtString(S)(S)
90 {
91 dstring zoneStr;
92
93 try
94 SimpleTimeZone.fromISOExtString(zoneStr);
95
96 catch (DateTimeException e) {}
97 }
98 }
99
100 template Select(bool condition, T...)
101 {
102 alias Select = Alias!(T[condition]);
103 }