www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15527] New: Template instantiation uses same-name symbol from

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

          Issue ID: 15527
           Summary: Template instantiation uses same-name symbol from
                    different scope as template alias parameter
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: epi atari8.info

Code (test.d):

struct Foo(alias Bar) {
    pragma(msg, typeof(Bar));
}

struct Baz {}
struct Quux {}

void main()
{
    {
        auto b = Baz();
        Foo!b foo1;
    }
    {
        auto r = Quux();
        Foo!r foo2;
    }
}

$ dmd test.d 
Baz
Quux

All good, there are two distinct instantiations.
However, if the variable in the second scope is renamed to b:
    {
        auto b = Baz();
        Foo!b foo1;
    }
    {
        auto b = Quux();
        Foo!b foo2;
    }

$ dmd test.d 
Baz

Foo is not instantiated again with the other b of type Quux.

--
Jan 07 2016