[dmd-internals] Type mangling for deduced attributes

Don Clugston dclugston at googlemail.com
Thu Nov 17 03:37:27 PST 2011


Another interesting case:

// This is just a trick to get a delegate literal into an alias.
template XX(alias Z)
{
    alias Z XX;
}
alias XX!( (){ return 2; }) Q;

pragma(msg, Q.stringof);
pragma(msg, typeof(Q).stringof);
=================
__dgliteral1
int delegate() pure nothrow @safe

I can't see any reason for the delegate literal to be stored in the
.di file. Surely the compiler could legally just put __dgliteral1 in
it.
This whole thing is pretty nasty.


On 17 November 2011 12:01, Don Clugston <dclugston at googlemail.com> wrote:
> On 17 November 2011 11:09, kenji hara <k.hara.pg at gmail.com> wrote:
>> Withdraw a previous statement, I still argue that is better to apply
>> result of inference into mangleof.
>> First of all, the pure/safe/nothrow inference runs against only
>> function literals and template functions.
>
> This is true at present. But are we confident that it will never apply
> to anything else?
>
>> For function literal, its
>> type determines in the place its written.For template function, its
>> type determines in its instantiation.Both of cases can always see
>> their function bodies.
>
> Are we happy to say that when full type inference is used, it does NOT
> invoke safe/pure/nothrow inference?
>
> immutable fptr = &foo!(7);
> immutable fptr2 = (){ return 0; }
>
> That is, both fptr and fptr2 will always be impure, @system, and throw?
> Or does it invoke safe/pure/nothrow inference? In which case the
> situation I mentioned arises.
>


More information about the dmd-internals mailing list