Jump to page: 1 2
Thread overview
[Issue 10619] Ambiguous mangling of local variable alias arguments to templates
[Issue 10619] Out-of-scope variable in a nested scope shadowed by subsequent variable in outer scope
Jul 26, 2015
Kenji Hara
Jul 27, 2015
Sönke Ludwig
Jul 27, 2015
Kenji Hara
Jul 27, 2015
Kenji Hara
[Issue 10619] Wrong local variable passed as alias arguments to templates
Feb 27, 2021
Dlang Bot
Feb 27, 2021
Ketmar Dark
Feb 28, 2021
Dlang Bot
Mar 06, 2021
Dlang Bot
July 16, 2014
https://issues.dlang.org/show_bug.cgi?id=10619

--- Comment #1 from hsteoh@quickfur.ath.cx ---
Looks like the problem is that the mangling of both instances of 'dg' is identical, so the compiler thinks that they are the same function.

--
July 16, 2014
https://issues.dlang.org/show_bug.cgi?id=10619

--- Comment #2 from hsteoh@quickfur.ath.cx ---
A slightly simpler test case:
-----
import std.stdio;

void myFunc(alias Sym)()
{
        writefln("%s", Sym);
}

void main()
{
        {
                {
                        int x = 789;
                        myFunc!x();
                }

                int x = 456;
                myFunc!x();
        }

        int x = 123;
        myFunc!x();
}
-----

Expected output:
-----
789
456
123
-----

Actual output:
-----
789
789
789
-----

--
July 16, 2014
https://issues.dlang.org/show_bug.cgi?id=10619

--- Comment #3 from hsteoh@quickfur.ath.cx ---
A clearly legal case that's currently broken:
----
import std.stdio;
void myFunc(alias Sym)()
{
        writeln(Sym);
}
void main()
{
        foreach (i; 0..3) {
                myFunc!i();
        }
        foreach (i; 5..8) {
                myFunc!i();
        }
}
----

Expected output:
----
0
1
2
5
6
7
----

Actual output:
----
0
1
2
2
2
2
----

The two instances of 'i' are clearly in distinct scopes, yet they are conflated in the mangling of myFunc, leading to wrong generated code.

--
July 16, 2014
https://issues.dlang.org/show_bug.cgi?id=10619

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Out-of-scope variable in a  |Ambiguous mangling of local
                   |nested scope shadowed by    |variable alias arguments to
                   |subsequent variable in      |templates
                   |outer scope                 |

--
July 16, 2014
https://issues.dlang.org/show_bug.cgi?id=10619

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--
July 26, 2015
https://issues.dlang.org/show_bug.cgi?id=10619

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |14831

--
July 27, 2015
https://issues.dlang.org/show_bug.cgi?id=10619

Sönke Ludwig <sludwig@outerproduct.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sludwig@outerproduct.org

--- Comment #4 from Sönke Ludwig <sludwig@outerproduct.org> ---
I assume that this has the same root cause:

---
void checkAlias(X...)(int cmp) { assert(X[0] == cmp); }

void main() {
    foreach (j; 0 .. 2) {
        if (j == 0) {
            int i = 42;
            checkAlias!(i)(i); // succeeds (42 == 42)
        } else {
            int i = 13;
            checkAlias!(i)(i); // fails (42 == 13)
        }
    }
}
---

This is a reduced test case of https://github.com/rejectedsoftware/vibe.d/issues/863

--
July 27, 2015
https://issues.dlang.org/show_bug.cgi?id=10619

--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to Sönke Ludwig from comment #4)
> I assume that this has the same root cause:
> 
> ---
> void checkAlias(X...)(int cmp) { assert(X[0] == cmp); }
> 
> void main() {
> 	foreach (j; 0 .. 2) {
> 		if (j == 0) {
> 			int i = 42;
> 			checkAlias!(i)(i); // succeeds (42 == 42)
> 		} else {
> 			int i = 13;
> 			checkAlias!(i)(i); // fails (42 == 13)
> 		}
> 	}
> }
> ---
> 
> This is a reduced test case of https://github.com/rejectedsoftware/vibe.d/issues/863

Yes, it's same issue.

--
July 27, 2015
https://issues.dlang.org/show_bug.cgi?id=10619

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> ---


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

--
February 26, 2021
https://issues.dlang.org/show_bug.cgi?id=10619
Issue 10619 depends on issue 14831, which changed state.

Issue 14831 Summary: Each function local symbols should have unique mangled name https://issues.dlang.org/show_bug.cgi?id=14831

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WORKSFORME

--
« First   ‹ Prev
1 2