Bug 11595 – __traits(allMembers, packageName) behaves oddly.

Status
RESOLVED
Resolution
DUPLICATE
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-24T12:33:52Z
Last change time
2022-09-29T14:23:21Z
Assigned to
No Owner
Creator
Shammah Chancellor

Comments

Comment #0 by shammah.chancellor — 2013-11-24T12:33:52Z
I have: module messages; public import messages.chat; public import messages.auth; public import messages.channel; public import messages.core; from messages.core.d: pragma(msg, __traits(allMembers, messages); prints: tuple("object", "std", "vibe", "client", "user", "channels", "messages", "ChatMessage", "PrivateMessage") prints the standard D objects for that package.d, but also the items in messages.auth, but NOTHING from the other public imports. I would not expect it to print anything but the D objects and the modulename's for the modules being imported. It doesn't seem to be possible to reflect on modules, and then on elements in modules at the current time as there is also no way to get an identifier back for a package from it's string returned from allMembers.
Comment #1 by sigod.mail — 2014-06-22T14:37:09Z
Comment #2 by blm768 — 2015-11-28T17:54:31Z
A more minimal test case: --- module main; import core.thread; //Broken: pragma(msg, __traits(allMembers, core)); //Seems to work: pragma(msg, __traits(allMembers, core.thread)); void main() {} --- The interesting thing is that the issue only seems to surface for root packages. In the backend source, when working with __traits (see traits.d), most package symbols have been resolved to Package objects, but root package names haven't been fully resolved; they're still Import objects. That's probably related to this issue.
Comment #3 by dkorpel — 2022-09-29T14:23:21Z
Output has changed: ``` 2.088.1: Success with output: ----- tuple("object", "core", "rt_tlsgc_init", "rt_tlsgc_destroy", "ScanDg", "rt_tlsgc_scan", "rt_tlsgc_processGCMarks", "StackGrowsDown", "getpid", "ThreadException", "ThreadError", "rt_moduleTlsCtor", "rt_moduleTlsDtor", "_d_eh_swapContext", "_d_eh_swapContextDwarf", "swapContext", "thread_entryPoint", "suspendCount", "thread_suspendHandler", "thread_resumeHandler", "Thread", "thread_setGCSignals", "suspendSignalNumber", "resumeSignalNumber", "thread_init", "_mainThreadStore", "_d_monitordelete_nogc", "thread_term", "thread_isMainThread", "thread_attachThis", "attachThread", "thread_detachThis", "thread_detachByAddr", "thread_detachInstance", "thread_findByAddr", "thread_setThis", "thread_joinAll", "_sharedStaticDtor_L2427_C1", "multiThreadedFlag", "callWithStackShell", "suspendDepth", "suspend", "thread_suspendAll", "resume", "thread_resumeAll", "ScanType", "ScanAllThreadsFn", "ScanAllThreadsTypeFn", "thread_scanAllType", "scanAllTypeImpl", "thread_scanAll", "thread_enterCriticalRegion", "thread_exitCriticalRegion", "thread_inCriticalRegion", "onThreadError", "IsMarked", "IsMarkedDg", "thread_processGCMarks", "pthread_getattr_np", "getStackTop", "getStackBottom", "thread_stackTop", "thread_stackBottom", "ThreadGroup", "AsmX86_64_Posix", "AlignFiberStackTo16Byte", "PAGESIZE", "PTHREAD_STACK_MIN", "_sharedStaticCtor_L3695_C1", "fiber_entryPoint", "fiber_switchContext", "Fiber", "ThreadID", "ll_ThreadData", "ll_nThreads", "ll_pThreads", "ll_lock", "lowlevelLock", "initLowlevelThreads", "termLowlevelThreads", "ll_removeThread", "createLowLevelThread", "joinLowLevelThread", "findLowLevelThread") tuple("object", "core", "rt_tlsgc_init", "rt_tlsgc_destroy", "ScanDg", "rt_tlsgc_scan", "rt_tlsgc_processGCMarks", "StackGrowsDown", "getpid", "ThreadException", "ThreadError", "rt_moduleTlsCtor", "rt_moduleTlsDtor", "_d_eh_swapContext", "_d_eh_swapContextDwarf", "swapContext", "thread_entryPoint", "suspendCount", "thread_suspendHandler", "thread_resumeHandler", "Thread", "thread_setGCSignals", "suspendSignalNumber", "resumeSignalNumber", "thread_init", "_mainThreadStore", "_d_monitordelete_nogc", "thread_term", "thread_isMainThread", "thread_attachThis", "attachThread", "thread_detachThis", "thread_detachByAddr", "thread_detachInstance", "thread_findByAddr", "thread_setThis", "thread_joinAll", "_sharedStaticDtor_L2427_C1", "multiThreadedFlag", "callWithStackShell", "suspendDepth", "suspend", "thread_suspendAll", "resume", "thread_resumeAll", "ScanType", "ScanAllThreadsFn", "ScanAllThreadsTypeFn", "thread_scanAllType", "scanAllTypeImpl", "thread_scanAll", "thread_enterCriticalRegion", "thread_exitCriticalRegion", "thread_inCriticalRegion", "onThreadError", "IsMarked", "IsMarkedDg", "thread_processGCMarks", "pthread_getattr_np", "getStackTop", "getStackBottom", "thread_stackTop", "thread_stackBottom", "ThreadGroup", "AsmX86_64_Posix", "AlignFiberStackTo16Byte", "PAGESIZE", "PTHREAD_STACK_MIN", "_sharedStaticCtor_L3695_C1", "fiber_entryPoint", "fiber_switchContext", "Fiber", "ThreadID", "ll_ThreadData", "ll_nThreads", "ll_pThreads", "ll_lock", "lowlevelLock", "initLowlevelThreads", "termLowlevelThreads", "ll_removeThread", "createLowLevelThread", "joinLowLevelThread", "findLowLevelThread") ----- 2.089.1 to 2.093.1: Success with output: ----- tuple("object", "core") tuple() ----- Since 2.094.2: Success with output: ----- tuple("object", "core") tuple("object", "core") ----- ``` But it's still not great, see issue 20008. *** This issue has been marked as a duplicate of issue 20008 ***