Bug 14375 – static assert leads to __traits(allMembers) retuning an extra empty entry

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-03-29T21:47:00Z
Last change time
2015-06-17T21:04:39Z
Assigned to
nobody
Creator
pro.mathias.lang

Comments

Comment #0 by pro.mathias.lang — 2015-03-29T21:47:11Z
This confuses MemberFunctionsTuple alot: /usr/include/dlang/dmd/std/traits.d(3647): Error: string expected as second argument of __traits hasMember instead of "" Tested with GDC (2.065), LDC (2.066.1) and 2.067 ```` class IKeysAPI(string greetings) { static assert(greetings == "Hello world", greetings); } void main() { foreach (method; __traits(allMembers, IKeysAPI!("Hello world"))) { static assert (method.length, "Empty string from the compiler ??"); pragma(msg, method); } } ```` Commenting the static assert makes the foreach pass.
Comment #1 by alphaglosined — 2015-03-30T02:35:41Z
The fix for this is very simple. https://github.com/rikkimax/dmd/blob/master/src/traits.c#L875 It is untested but it is there. Ironically this has been as a PR since before 2.066. https://github.com/D-Programming-Language/dmd/pull/3921 I've tested it on a built executable locally with that PR added. Works fine.
Comment #2 by ketmar — 2015-03-30T04:47:05Z
i'm using 3921 PR for a long time in my DMD branch, and i can ack that it is working without any noticeable troubles.
Comment #3 by github-bugzilla — 2015-04-11T15:19:45Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2dfede5829685a97e58f7d32f1d3b6448b4969e4 Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry https://github.com/D-Programming-Language/dmd/commit/714d1b32cfe721e6266ebbc096355c8ce109f8b8 Merge pull request #4578 from Geod24/fix-14375 Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry
Comment #4 by github-bugzilla — 2015-04-23T23:00:17Z
Commit pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bbe9fd2bd561d2b1c72f246d30fd1d9681d8dfe1 Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry
Comment #5 by github-bugzilla — 2015-04-26T00:04:47Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bbe9fd2bd561d2b1c72f246d30fd1d9681d8dfe1 Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry
Comment #6 by github-bugzilla — 2015-06-17T21:04:39Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2dfede5829685a97e58f7d32f1d3b6448b4969e4 Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry https://github.com/D-Programming-Language/dmd/commit/714d1b32cfe721e6266ebbc096355c8ce109f8b8 Merge pull request #4578 from Geod24/fix-14375