D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13617 - alias with scopes
Summary: alias with scopes
Status: RESOLVED DUPLICATE of issue 11521
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: wrong-code
: 15527 (view as issue list)
Depends on:
Blocks:
 
Reported: 2014-10-14 21:00 UTC by jens.k.mueller
Modified: 2020-08-09 10:50 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description jens.k.mueller 2014-10-14 21:00:16 UTC
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 Ketmar Dark 2014-10-14 23:34:28 UTC
it's definetely a bug. there is no sane explanation why both tests using 'int a' here.
Comment 2 yebblies 2014-12-07 03:35:21 UTC
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 Kenji Hara 2016-03-18 12:35:54 UTC
*** Issue 15527 has been marked as a duplicate of this issue. ***
Comment 4 Walter Bright 2020-08-09 10:50:45 UTC

*** This issue has been marked as a duplicate of issue 11521 ***