Bug 5957 – Ambiguous mangling of module and template in template symbol args

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-05-08T08:50:17Z
Last change time
2024-12-13T17:55:11Z
Assigned to
No Owner
Creator
kennytm
Moved to GitHub: dmd#18339 →

Comments

Comment #0 by kennytm — 2011-05-08T08:50:17Z
Consider the program: ---------------------------- module y; import std.typecons; template f(alias s) { void f() { } } void g(){} void main() { f!( std.typecons )(); // A f!( f )(); // B f!( g )(); // C } ---------------------------- The manglings are: A: _D1y22__T1fS133std8typeconsZ1fFZv **^^^^^^^^^^^^^ B: _D1y12__T1fS41y1fZ1fFZv *^^^^ C: _D1y17__T1fS9_D1y1gFZvZ1fFZv *^^^^^^^^^ Here, the module 'std.typecons' and 'f' are simply encoded as a QualifiedName, unlike 'g' which is encoded as a MangledName. However, with this it is very hard for the demangler to tell the QualifiedName in A and B only have 13 and 4 characters respectively, instead of 133 and 41. There should be some separator between the 13/4 and the 3/1, or a type should be defined for module and templates, and encode them with MangledName instead of QualifiedName.
Comment #1 by kennytm — 2011-05-08T10:35:26Z
To show that this bug does affect code more than the demangler, consider the following programs: ----------------------------------- // a146zzzzzza.d template b(){} ----------------------------------- // a.d template zzzzzza1bTC1y130bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggffffffffffgggggggggg(){} ----------------------------------- // y.d module y; import a146zzzzzza; import a; import std.stdio; class bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggffffffffffgggggggggg {} template f(s...) { void f(){ writeln(s.stringof); } } void main() { f!( a146zzzzzza.b, bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggffffffffffgggggggggg )(); f!( a.zzzzzza1bTC1y130bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggffffffffffgggggggggg )(); } ----------------------------------- The output is: tuple(b(),(bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggffffffffffgggggggggg)) tuple(b(),(bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggffffffffffgggggggggg)) as we can see, the 2nd function is shadowed by the 1st as they share the same symbol: _D1y161__T1fS1511a146zzzzzza1bTC1y130bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggffffffffffggggggggggZ1fFZv
Comment #2 by lt.infiltrator — 2014-03-19T18:05:59Z
Related to Issue 4268?
Comment #3 by robert.schadek — 2024-12-13T17:55:11Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18339 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB