Jump to page: 1 2
Thread overview
[Issue 17545] [REG2.072] __traits(getAttributes, name) evaluates name to value prematurely
[Issue 17545] [REG2.072] __traits(getMember, mod, name) evaluates enum to value prematurely
Jun 24, 2017
Ketmar Dark
Jun 24, 2017
Vladimir Panteleev
Jun 29, 2017
Walter Bright
Jun 29, 2017
Walter Bright
June 24, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry

--
June 24, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[REG2.072]                  |[REG2.072]
                   |__traits(getMember, mod,    |__traits(getAttributes,
                   |name) evaluates enum to     |name) evaluates name to
                   |value prematurely           |value prematurely

--
June 24, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

monkeyworks12@hotmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monkeyworks12@hotmail.com

--- Comment #1 from monkeyworks12@hotmail.com ---
This code is *supposed* to be equivalent as far as I know, but it actually fixes the issue. Change `@Attrib enum TEST = 123` to `@Attrib enum TEST { val = 123; }` and it will compile (you can also make it immutable; basically anything that introduces an actual symbol).

I think it's because the compiler does not even see the enum; the symbol TEST is replaced with the actual value at the usage site so it's like you're doing `pragma(msg, __traits(getAttributes, 123))`, which of course doesn't make any sense.

--
June 24, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
June 24, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

--- Comment #2 from monkeyworks12@hotmail.com ---
If you don't want to modify the enum the following code also seems to work. The main thing is to avoid using __traits(getMember) which could get passed a non-symbol.

module example;
import std.meta: staticIndexOf;
import std.traits;

struct Attrib {}

@Attrib enum TEST = 123;

void foo() {
    foreach(sym; getSymbolsByUDA!(example, Attrib)) {
        pragma(msg, sym.stringof); //Prints 123
    }
}

The fact that it prints 123 instead of TEST seems to suggest that it is indeed a problem with the compiler pasting the value where the identifier is used. I'd recommend taking a look at the implementation of getSymbolsByUDA to see how it's done there.

--
June 24, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net

--- Comment #3 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Introduced in https://github.com/dlang/dmd/pull/5588

--
June 29, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Vladimir Panteleev from comment #3)
> Introduced in https://github.com/dlang/dmd/pull/5588

Timon Gehr notes that it was this diff that caused the issue:

https://github.com/dlang/dmd/compare/master...tgehr:fix17545

--
June 29, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/6949

--
July 09, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/2e6c7ac3af5ec52aff63a779e781cab1a802dfa5 fix Issue 17545 - [REG2.072] __traits(getAttributes, name) evaluates name to value prematurely

https://github.com/dlang/dmd/commit/1227633d355b0a6ab8f65d82247fcf0d5012129e Merge pull request #6949 from WalterBright/fix17545

fix Issue 17545 - [REG2.072] __traits(getAttributes, name) evaluates … merged-on-behalf-of: Martin Nowak <code@dawg.eu>

--
July 09, 2017
https://issues.dlang.org/show_bug.cgi?id=17545

github-bugzilla@puremagic.com changed:

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

--
« First   ‹ Prev
1 2