[dmd-internals] Correction to name mangling doc

Sean Kelly sean at invisibleduck.org
Fri May 20 15:02:17 PDT 2011


On Aug 31, 2010, at 12:06 AM, Don Clugston wrote:

> On 31 August 2010 05:58, Sean Kelly <sean at invisibleduck.org> wrote:
>> One other thing.  The ABI has "i Number" under "Value" for templates, but demangle() doesn't handle this and the ABI is totally silent on what it is.  Any idea?  I suppose I could just check the DMD source though.
> 
> Svn 370. Which I think was a really bad idea. The i should always be
> there, for any positive number. It's a fantasy to think that the ABI
> is stable at this point (eg, bug 3398 "Attributes inside a union
> screws data alignment" has only just been fixed). We could fix all
> remaining ABI issues in one go, then declare it stable.

I just ran into this one, and it's an annoyance more than anything else.  The function:

    fn!([1:2, 3:4])();

is mangled as:

    _D8demangle21__T2fnVHiiA2i1i2i3i4Z2fnFZv

The pertinent part being the way associative arrays are mangled:

    HiiA2i1i2i3i4

The type is "Hii", so an AA of int->int.  Perfect.  But then the value is "A2i1i2i3i4", which taken by itself suggests an array literal, not an AA literal.  This is the only instance that I've encountered where the determined type has to be communicated to the value parser so it can demangle things correctly (since it would be otherwise treated as a plain old array literal and represented as "[1,2]").  It would be better if the representation for this AA were:

    HiiH2i1i2i3i4

Thoughts?


More information about the dmd-internals mailing list