Thread overview
[Issue 11521] Collision of templates instantiated with different same-named locals
Jul 21, 2017
Vladimir Panteleev
Aug 09, 2020
Walter Bright
Aug 09, 2020
Walter Bright
Aug 09, 2020
Walter Bright
July 21, 2017
https://issues.dlang.org/show_bug.cgi?id=11521

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|Switch using same name      |Collision of templates
                   |variable leads to Access    |instantiated with different
                   |Violation                   |same-named locals
           Severity|normal                      |critical

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Reduced:

////// test.d /////
void fun(alias x)()
{
    assert(x == 1);
}

void main()
{
    if (false)
    {
        int i = 0;
        fun!i();
    }

    {
        int i = 1;
        fun!i();
    }
}
///////////////////

The problem is that both fun!i instantiations have the same mangled name, even though they refer to different variables and have different code.

The mangled name of local variables should have some sort of index in them.

--
August 09, 2020
https://issues.dlang.org/show_bug.cgi?id=11521

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
If they're declared as 'static' the current compiler will issue an error about a name collision. Any fix for this should use a similar mechanism.

--
August 09, 2020
https://issues.dlang.org/show_bug.cgi?id=11521

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=13617

--
August 09, 2020
https://issues.dlang.org/show_bug.cgi?id=11521

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jens.k.mueller@gmx.de

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
*** Issue 13617 has been marked as a duplicate of this issue. ***

--
July 05, 2021
https://issues.dlang.org/show_bug.cgi?id=11521

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg
         Resolution|---                         |FIXED

--- Comment #4 from moonlightsentinel@disroot.org ---
Fixed in 2.096.1

--