Bug 13617 – alias with scopes

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-10-14T21:00:16Z
Last change time
2020-08-09T10:50:45Z
Keywords
wrong-code
Assigned to
No Owner
Creator
jens.k.mueller
See also
https://issues.dlang.org/show_bug.cgi?id=3031, https://issues.dlang.org/show_bug.cgi?id=11521

Comments

Comment #0 by jens.k.mueller — 2014-10-14T21:00:16Z
I find the behavior of the following code unexpected. bool foo(alias f)() { return is(typeof(f) == int); } unittest { { int a; static assert(foo!a); } { float a; static assert(foo!a); // passes unexpectedly } } The second assert passes unexpectedly. If you change the variable name to b it fails as expected. Bug or not so unexpected behavior? To me it's a bug. But maybe there is a explanation that I'm not aware of. The same behavior is observed when foo is defined as a template. This is dmd v2.066.0 on Linux.
Comment #1 by ketmar — 2014-10-14T23:34:28Z
it's definetely a bug. there is no sane explanation why both tests using 'int a' here.
Comment #2 by yebblies — 2014-12-07T03:35:21Z
This has the same cause as issue 12244 and issue 3031 - function-local symbols do not have unique names and conflict with symbols in sibling scopes.
Comment #3 by k.hara.pg — 2016-03-18T12:35:54Z
*** Issue 15527 has been marked as a duplicate of this issue. ***
Comment #4 by bugzilla — 2020-08-09T10:50:45Z
*** This issue has been marked as a duplicate of issue 11521 ***