Debian Codegraph @

gcc/testsuite/gdc.test/compilable/aliasdecl.d

raw
1 template Test(T){ alias Type = T; }
2
3 alias X1 = int;
4 static assert(is(X1 == int));
5
6 alias X2 = immutable(long)[], X3 = shared const double[int];
7 static assert(is(X2 == immutable(long)[]));
8 static assert(is(X3 == shared const double[int]));
9
10 alias X4 = void delegate() const, X5 = Test!int;
11 static assert(is(X4 == void delegate() const));
12 static assert(is(X5.Type == int));
13
14 alias FP5 = extern(C) pure nothrow @safe @nogc void function(),
15 DG5 = extern(D) pure nothrow @safe @nogc void delegate();
16 static assert(FP5.stringof == "extern (C) void function() pure nothrow " /* ~ "@safe " */ ~ "@nogc");
17 static assert(DG5.stringof == "void delegate() pure nothrow " /* ~ "@safe " */ ~ "@nogc");
18
19 void main()
20 {
21 alias Y1 = int;
22 static assert(is(Y1 == int));
23
24 alias Y2 = immutable(long)[], Y3 = shared const double[int];
25 static assert(is(Y2 == immutable(long)[]));
26 static assert(is(Y3 == shared const double[int]));
27
28 alias Y4 = void delegate() const, Y5 = Test!int;
29 static assert(is(Y4 == void delegate() const));
30 static assert(is(Y5.Type == int));
31
32 // https://issues.dlang.org/show_bug.cgi?id=18429
33 struct S
34 {
35 alias a this;
36 enum a = 1;
37 }
38
39 struct S2
40 {
41 int value;
42 alias this = value;
43 }
44 auto s = S2(10);
45 int n = s;
46 assert(n == 10);
47 }