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 #2947 from 9rnsr/fix11720
Issue 11720 - Function-local static variables should cause "already defined in another scope" error
- Loading branch information
Showing
2 changed files
with
50 additions
and
11 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,33 @@ | ||
// REQUIRED_ARGS: -o- | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail11720.d(23): Error: declaration fail11720.foo!().foo.temp is already defined in another scope in foo | ||
fail_compilation/fail11720.d(13): Error: template instance fail11720.foo!() error instantiating | ||
fail_compilation/fail11720.d(31): Error: declaration fail11720.bar.temp is already defined in another scope in bar | ||
--- | ||
*/ | ||
|
||
void main() | ||
{ | ||
foo(); | ||
bar(); | ||
} | ||
|
||
alias TypeTuple(T...) = T; | ||
|
||
void foo()() | ||
{ | ||
foreach (T; TypeTuple!(int, double)) | ||
{ | ||
static temp = T.stringof; | ||
} | ||
} | ||
|
||
void bar() | ||
{ | ||
foreach (T; TypeTuple!(int, double)) | ||
{ | ||
static temp = T.stringof; | ||
} | ||
} |