-
-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 23598 - Circular reference bug with static if and eponymous…
… templates (#14838)
- Loading branch information
1 parent
fbf8061
commit 4791e9e
Showing
10 changed files
with
154 additions
and
12 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
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
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
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,87 @@ | ||
// https://issues.dlang.org/show_bug.cgi?id=23598 | ||
|
||
alias AliasSeq(a...) = a; | ||
|
||
static if (1) | ||
{ | ||
|
||
template sort(alias f, a...) | ||
{ | ||
static if (a.length > 0) | ||
{ | ||
alias x = f!(a[0]); | ||
alias sort = a; | ||
} | ||
else | ||
alias sort = a; | ||
} | ||
|
||
alias SortedItems = sort!(isDependencyOf, String); | ||
|
||
enum isDependencyOf(Item) = Item.DirectDependencies.length == 0; | ||
|
||
struct String | ||
{ | ||
alias DirectDependencies = AliasSeq!(); | ||
|
||
enum l = SortedItems.length; // (3) | ||
} | ||
|
||
} | ||
|
||
/*****************************************************/ | ||
|
||
static if (1) | ||
{ | ||
enum x = 1; | ||
enum y = 2; | ||
|
||
template f(T) | ||
{ | ||
alias b = int; | ||
static if (x) | ||
{ | ||
alias c = x; | ||
} | ||
else | ||
{ | ||
alias c = y; | ||
} | ||
|
||
static if (is(typeof(c))) | ||
{ | ||
} | ||
else | ||
{ | ||
static assert(0); | ||
} | ||
} | ||
|
||
void g() | ||
{ | ||
int x = f!int.c; | ||
} | ||
} | ||
|
||
/*****************************************************/ | ||
|
||
template forward(args...) | ||
{ | ||
template fwd(alias arg) | ||
{ | ||
alias fwd = arg; | ||
} | ||
|
||
alias Result = AliasSeq!(); | ||
static foreach (arg; args) | ||
Result = AliasSeq!(Result, fwd!arg); | ||
static if (Result.length == 1) | ||
alias forward = Result[0]; | ||
else | ||
alias forward = Result; | ||
} | ||
|
||
void func(int i, int j) | ||
{ | ||
func(forward!(i, j)); | ||
} |
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