[Issue 17974] New: getSymbolsByUDA is returns unusable symbols when used in foreach
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 8 19:21:09 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17974
Issue ID: 17974
Summary: getSymbolsByUDA is returns unusable symbols when used
in foreach
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: kolos80 at bk.ru
First things first (omitting irrelevant portions):
$ dmd --version
DMD64 D Compiler v2.077.0
$ pacman -Qi libphobos
Version : 1:2.077.0-1
Now, getSymbolsByUDA is completely unusable when used in `foreach' loops.
First, the symbols it returns seem to be lacking the attribute in question:
// main.d
import std.traits;
enum Attr;
static struct FUBAR
{
@Attr int a;
void dummy()
{
foreach (symbol; getSymbolsByUDA!(FUBAR, Attr))
static assert(hasUDA!(symbol, Attr));
}
}
Tried to compile it with `dmd -c main.d', got this:
src/main.d(11): Error: static assert hasUDA!(symbol, Attr) is false
Commented out the loop and added this:
void main()
{
static assert(hasUDA!(getSymbolsByUDA!(FUBAR, Attr), Attr));
foreach (symbol; getSymbolsByUDA!(FUBAR, Attr))
static assert(hasUDA!(symbol, Attr));
}
And now it makes even less sense:
src/main.d(18): Error: need 'this' for 'a' of type 'int'
src/main.d(19): while evaluating: static assert(hasUDA!(symbol, Attr))
So it has the attribute in `static assert', but doesn't in `foreach'. What's
going on?
--
More information about the Digitalmars-d-bugs
mailing list