https://issues.dlang.org/show_bug.cgi?id=12579

Kenji Hara <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Kenji Hara <[email protected]> ---
(In reply to brian-schott from comment #0)
> void function() foo = {};
> 
> According to the grammar spec, the latter should be parsed as a variable
> declaration whose type is "void function()", with a name of "foo" and an
> empty struct initializer. (By the way, the grammar does not allow empty
> struct initializers). This should not pass semantic analysis because a
> struct literal is not of type void function().

StructInitializer is defined as follows:

StructInitializer:
    { StructMemberInitializers_opt }

Between braces StructMemberInitializers is optional, so {} is properly
accepted.

And, If a delegate variable is initialized by empty StructInitializer, it is
treated as a function literal in semantic phase.

https://github.com/D-Programming-Language/dmd/blob/d4f778f96a85de9605a035864d3480e40097df28/src/init.c#L287

--

Reply via email to