www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13617] New: alias with scopes

https://issues.dlang.org/show_bug.cgi?id=13617

          Issue ID: 13617
           Summary: alias with scopes
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: jens.k.mueller gmx.de

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.

--
Oct 14 2014