Thread overview
[Issue 21352] enum members should not be given UDAs of its parent enum declaration
Oct 31
Basile-z
Oct 31
Dlang Bot
Nov 01
RazvanN
Jan 07
Dlang Bot
October 31
https://issues.dlang.org/show_bug.cgi?id=21352

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|enum members should not be  |enum members should not be
                   |given UDAs of type          |given UDAs of its parent
                   |                            |enum declaration

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
I hope the new title is ok as the old one was slightly ambiguous

--
October 31
https://issues.dlang.org/show_bug.cgi?id=21352

Dlang Bot <dlang-bot@dlang.rocks> changed:

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

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@BorisCarvajal created dlang/dmd pull request #11917 "Fix Issue 21352 - enum members should not be given UDAs of its parent…" fixing this issue:

- Fix Issue 21352 - enum members should not be given UDAs of its parent enum declaration

https://github.com/dlang/dmd/pull/11917

--
November 01
https://issues.dlang.org/show_bug.cgi?id=21352

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to SHOO from comment #0)
> This code is broken:
> --------------------------------
> @("aaa") enum Hoge {
> 	@("bbb") foo, // tuple("aaa", "bbb") -> should be only tuple("bbb")
> 	bar,  // tuple()
> }
> @("aaa") struct Fuga {
> 	@("bbb") int foo; // tuple("bbb")
> 	int bar; // tuple()
> }
> static assert([__traits(getAttributes, Hoge.foo)] == ["bbb"]); //NG
> static assert([__traits(getAttributes, Hoge.bar)] == []);
> static assert([__traits(getAttributes, Fuga.foo)] == ["bbb"]);
> static assert([__traits(getAttributes, Fuga.bar)] == []);
> --------------------------------

I am not convinced this is the right fix. From the spec: "If there are multiple UDAs in scope for a declaration, they are concatenated" and the example given is:

@(1)
{
    @(2) int a;         // has UDAs (1, 2)
    @("string") int b;  // has UDAs (1, "string")
}

>From this it seems that if the declaration introduces a scope, then the UDA is
going to be propagated to the subsequent declarations. From my perspective, the real bug is that:

@("aaa") struct Fuga {
        @("bbb") int foo; // tuple("bbb")
        int bar; // tuple()
}

static assert([__traits(getAttributes, Fuga.foo)] == ["bbb"]); // should be
tuple("aaa", "bbb")


Since applying any qualifier to the struct declaration propagates it to all the
declarations in the structm why woud UDAs be
any different? I haven't found anything specifically in the spec that would
point that this PR is the right fix, but maybe I am missing something.

--
January 07
https://issues.dlang.org/show_bug.cgi?id=21352

Dlang Bot <dlang-bot@dlang.rocks> changed:

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

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11917 "Fix Issue 21352 - enum members should not be given UDAs of its parent…" was merged into master:

- 7c990f6061b1ea149fd68bc38eafab19ff8406b9 by Boris Carvajal:
  Fix Issue 21352 - enum members should not be given UDAs of its parent enum
declaration

https://github.com/dlang/dmd/pull/11917

--