-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 10619 - Wrong local variable passed as alias arguments to templates
PR #12119 introduced `localNum` to differentiate between multiple symbols with identical names. But `Dsymbol.equals` doesn't consider this variable when comparing two Dsymbols. This caused template semantic to treat the second instantiation of `foo` as a duplice in the following example: ```d void main() { { int x = 1; foo!x(); } { int x = 2; foo!x(); } } ```
- Loading branch information
1 parent
8fda115
commit 0c2d8bd
Showing
2 changed files
with
43 additions
and
1 deletion.
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,40 @@ | ||
/* | ||
https://issues.dlang.org/show_bug.cgi?id=10619 | ||
PERMUTE_ARGS: | ||
RUN_OUTPUT: | ||
--- | ||
1 | ||
1 | ||
3 | ||
4 | ||
--- | ||
print => 2 will be fixed by https://github.com/dlang/dmd/pull/12235 | ||
*/ | ||
|
||
void main() | ||
{ | ||
{ | ||
int x = 1; | ||
print!x(); | ||
} | ||
{ | ||
int x = 2; | ||
print!x(); | ||
} | ||
{ | ||
static int y = 3; | ||
print!y(); | ||
} | ||
{ | ||
static int y = 4; | ||
print!y(); | ||
} | ||
} | ||
|
||
void print(alias symbol)() | ||
{ | ||
import core.stdc.stdio : printf; | ||
printf("%d\n", symbol); | ||
} |