Bug 17432 – [DIP1000] scope delegates change type, but not mangling
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-05-25T07:47:00Z
Last change time
2017-08-07T13:16:37Z
Assigned to
uplink.coder
Creator
r.sagitario
Comments
Comment #0 by r.sagitario — 2017-05-25T07:47:06Z
Consider this code:
/////////////////
module test;
int opApply(scope int delegate() dg) { return dg(); }
// stripped down version of std.traits.Parameters
template Parameters(alias func)
{
static if (is(typeof(func) P == function))
alias Parameters = P;
else
static assert(0, "unsupported");
}
alias op = Parameters!(opApply)[0];
enum typeString = op.stringof;
mixin(typeString ~ " dg;");
alias ty = typeof(dg);
pragma(msg, op.stringof ~ " -> " ~ op.mangleof);
pragma(msg, ty.stringof ~ " -> " ~ ty.mangleof);
/////////////////
Compiling with "dmd -c test.d" prints:
int delegate() -> DFZi
int delegate() -> DFZi
When compiled with "dmd -c -dip1000 test.d", dmd prints:
int delegate() scope -> DFZi
int delegate() scope -> DFNlZi
The type of the scope delegate parameter is modified adding "scope" as a function attribute, but this is not reflected in the mangling. When reusing its type elsewhere, the mangling is different.
This is currently blocking https://github.com/dlang/dmd/pull/5855 as it has to redo the mangling of the delegate whenever it happens to be part of another symbol.
Comment #1 by r.sagitario — 2017-05-25T07:48:53Z
For reference: The type repainting happens in TypeDelegate.addStorageClass()
Comment #2 by github-bugzilla — 2017-06-07T03:13:49Z