New __traits
BLM768 via Digitalmars-d
digitalmars-d at puremagic.com
Thu Nov 26 15:16:57 PST 2015
On Thursday, 26 November 2015 at 20:56:39 UTC, Jonathan M Davis
wrote:
> Yes, code can forward-reference an import. e.g. this code
> compiles just fine:
>
> void main()
> {
> writeln("Where's my import?");
> }
>
> import std.stdio;
>
> Now, when the import is inside of a function, then it can't be
> forward-referenced, but that's in line with how variable
> declarations work.
>
> - Jonathan M Davis
Oh, duh. I should have remembered that.
In any case, I my tests work when I forward-reference, too, so
I'll probably just put an assert on it and call it good. I've got
some unit tests on my code now, so it looks like it's almost time
for my first PR.
I don't know if this is at all related to how top-level packages
aren't resolving to Package objects by the time the __traits run,
but while testing this code, I found what seems to be a bug
related to __traits(allMembers). Specifically, this code produces
an extremely strange output:
---
import std.stdio;
pragma(msg, __traits(allMembers, std));
void main() {}
---
It lists a bunch of symbols that most certainly _aren't_ direct
ancestors of the "std" package: "object", "core", "std",
"KeepTerminator", "GCC_IO", "HAS_GETDELIM", "FSChar", and a bunch
of others.
That's a bug, right?
More information about the Digitalmars-d
mailing list