Bug 21812 – __traits(allMembers) on types with value tuples return ghost members
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-09T01:17:55Z
Last change time
2021-04-09T10:29:25Z
Keywords
pull, wrong-code
Assigned to
No Owner
Creator
Steven Schveighoffer
Comments
Comment #0 by schveiguy — 2021-04-09T01:17:55Z
Consider the following code:
-----
struct S(A...)
{
A args;
}
void main()
{
pragma(msg, __traits(allMembers, S!(int, float)));
}
----
This outputs the following:
tuple("args", "__args_field_0", "__args_field_1")
The members __args_field_0 and __args_field_1 don't exist on the type:
---
S!(int, float) s;
// all of these produce the error: no property __args_field_0 for type S!(int, float)
writeln(s.__args_field_0);
writeln(__traits(getMember, s, "__args_field_0"));
pragma(msg, __traits(identifier, __traits(getMember, typeof(s), "__args_field_0")));
---
I would contend that __traits(allMembers) should not ever return strings that are not accessible in any way as a member.
Comment #1 by dlang-bot — 2021-04-09T04:12:16Z
@BorisCarvajal updated dlang/dmd pull request #12406 "Fix Issue 21812 - __traits(allMembers) on types with value tuples return ghost members" fixing this issue:
- Fix Issue 21812 - __traits(allMembers) on types with value tuples return ghost members
https://github.com/dlang/dmd/pull/12406
Comment #2 by dlang-bot — 2021-04-09T06:46:16Z
dlang/dmd pull request #12406 "Fix Issue 21812 - __traits(allMembers) on types with value tuples return ghost members" was merged into master:
- cf228e6fba6ce2442fe9b379de4ec43f197f5d45 by Boris Carvajal:
Fix Issue 21812 - __traits(allMembers) on types with value tuples return ghost members
https://github.com/dlang/dmd/pull/12406
Comment #3 by dlang-bot — 2021-04-09T10:29:25Z
dlang/dmd pull request #12411 "[dmd-cxx] fix Issue 21813 - [REG-master] Bootstrap broken from dmd-cxx baseline" was merged into dmd-cxx:
- e6baffb834b4281da1ae7b1cc5c51225a392efb4 by Boris Carvajal:
[dmd-cxx] Fix Issue 21812 - __traits(allMembers) on types with value tuples return ghost members
https://github.com/dlang/dmd/pull/12411