null to delegate cast?
Ivan Senji
ivan.senji_REMOVE_ at _THIS__gmail.com
Mon Sep 11 15:06:39 PDT 2006
Stewart Gordon wrote:
> icee wrote:
>> In http://www.digitalmars.com/d/expression.html, you said
>> "A null is implicitly converted to a Type delegate() by creating an
>> anonymous delegate that returns null."
>>
>> But the truth seems not:
>>
>> //char[] delegate () dg = null; //cause av
>
> Do you mean:
> (a) that merely assigning null to a delegate variable causes an AV?
> (b) that calling dg afterwards causes an AV?
>
> (a) certainly shouldn't be happening. But if (b), of course it does.
> What else would it do?
>
> <snip>
>> const Type delegate() dgnull; // default initializer for delegate is
>> null
>> ....
>> Type delegate() dg1; // default initializer for delegate is null
>> Type delegate() dg2 = dgnull;
>> Type delegate() dg3 = (Type delegate()).init;
>> Type delegate() dg4 = cast(Type delegate()) null;
>>
>> Type delegate() dg5 = null; // initializes dg5 to
>> // delegate Type() { return null; }
>
> Case dg5 is certainly weird.
>
That is a leftover from implicit conversions of expressions (null in
this case) to delegates, it shouldn't be a problem any more.
More information about the Digitalmars-d-bugs
mailing list