Bug 23241 – __traits getMember breaks compilation when hit an alias

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2022-07-13T01:11:19Z
Last change time
2022-07-27T07:58:36Z
Keywords
pull
Assigned to
No Owner
Creator
ryuukk_

Comments

Comment #0 by ryuukk.dev — 2022-07-13T01:11:19Z
``` onlineapp.d(12): Error: first argument is not a symbol ``` ``` module a; import std; @("hi") void main() { alias THIS_MODULE = a; static foreach (member; __traits(allMembers, THIS_MODULE)) { writeln("member: ", member); static foreach (attr; __traits(getAttributes, __traits(getMember, THIS_MODULE, member))) { writeln("\tattribute: ", attr); } } } enum :int { A, B, C } // commenting this out fixes it alias MyEnum = int; ``` Expected behavior: It should ignore either ignore the alias and compile, or support the alias
Comment #1 by dlang-bot — 2022-07-13T02:54:35Z
@maxhaton created dlang/dmd pull request #14298 "Fix Issue 23241 - Consider types with no symbol (e.g. int) to have no…" fixing this issue: - Fix Issue 23241 - Consider types with no symbol (e.g. int) to have no attributes https://github.com/dlang/dmd/pull/14298
Comment #2 by dlang-bot — 2022-07-27T07:58:36Z
dlang/dmd pull request #14298 "Fix Issue 23241 - Consider types with no symbol (e.g. int) to have no…" was merged into master: - 251dbdf030280add92afea6fef45482926cc955d by mhh: Fix Issue 23241 - Consider types with no symbol (e.g. int) to have no attributes https://github.com/dlang/dmd/pull/14298