Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1187 from 9rnsr/fix3011
[enh] Issue 3011 - alias should have assignment syntax
- Loading branch information
Showing
2 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
template Test(T){ alias Type = T; } | ||
|
||
alias X1 = int; | ||
static assert(is(X1 == int)); | ||
|
||
alias X2 = immutable(long)[], X3 = shared const double[int]; | ||
static assert(is(X2 == immutable(long)[])); | ||
static assert(is(X3 == shared const double[int])); | ||
|
||
alias X4 = void delegate() const, X5 = Test!int; | ||
static assert(is(X4 == void delegate() const)); | ||
static assert(is(X5.Type == int)); | ||
|
||
void main() | ||
{ | ||
alias Y1 = int; | ||
static assert(is(Y1 == int)); | ||
|
||
alias Y2 = immutable(long)[], Y3 = shared const double[int]; | ||
static assert(is(Y2 == immutable(long)[])); | ||
static assert(is(Y3 == shared const double[int])); | ||
|
||
alias Y4 = void delegate() const, Y5 = Test!int; | ||
static assert(is(Y4 == void delegate() const)); | ||
static assert(is(Y5.Type == int)); | ||
|
||
struct S | ||
{ | ||
int value; | ||
alias this = value; | ||
} | ||
auto s = S(10); | ||
int n = s; | ||
assert(n == 10); | ||
} |