Thread overview
[Issue 13361] Empty UDA accepted
Aug 29, 2014
Kenji Hara
Aug 29, 2014
Orvid King
Aug 30, 2014
Kenji Hara
Aug 30, 2014
Kenji Hara
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13361

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
But UDA can take zero-length tuple, which is finally reduced to @().


alias TypeTuple(T...) = T;

alias args = TypeTuple!();  // zero-length tuple

      void foo() {}
@args void bar() {}
@()   void baz() {}

pragma(msg, __traits(getAttributes, foo).length);   // prints 0
pragma(msg, __traits(getAttributes, bar).length);   // prints 0
pragma(msg, __traits(getAttributes, baz).length);   // prints 0

Yes, it is useless, but I don't think it's invalid syntax.

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=13361

--- Comment #2 from Orvid King <blah38621@gmail.com> ---
A zero length tuple at least means something, but an explicitly empty UDA should be a syntax error. I believe that the only times it's possible for @() to actually be in the code is accidental, and so the compiler should be helpful in this case. @args should continue to be valid, and only @() should produce an error.

--
August 30, 2014
https://issues.dlang.org/show_bug.cgi?id=13361

--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> ---
OK, I confirmed that current grammar does not allow empty argument list.

http://dlang.org/attribute.html#UserDefinedAttribute

UserDefinedAttribute:
    @ ( ArgumentList )     // <--
    @ Identifier
    @ Identifier ( ArgumentList_opt )

ArgumentList is not optional, it should have one or more arguments.

--
August 30, 2014
https://issues.dlang.org/show_bug.cgi?id=13361

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/3920

--
August 30, 2014
https://issues.dlang.org/show_bug.cgi?id=13361

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7306d1d5228f0d4c901fe9ed77de955a1e515528 fix Issue 13361 - Empty UDA accepted

https://github.com/D-Programming-Language/dmd/commit/56a0fedaeb90dab89f1248498ec155ed2a372ae9 Merge pull request #3920 from 9rnsr/fix13361

Issue 13361 - Empty UDA accepted

--