There's no way to identify a custom version identifier as such. Example: --- module test; import std.traits : isCallable; version(all) version = my_version; private bool onlyFuncs() { bool result = true; foreach (member; __traits(allMembers, mixin(__MODULE__))) { static if (!is(mixin(member) == module) && !(is(mixin(member)))) static if (__traits(getOverloads, mixin(__MODULE__), member, true).length == 0) { pragma(msg, "`", member, "` ", "is not a type or a function"); result = false; break; } } return result; } static assert(onlyFuncs()); void main(){} --- Either custom version identifiers should be excluded from the traits results or we should be able to use them with a new variant of the isExpression, e.g `static if (is(mixin(member) == version))`
Instead of static if (!is(mixin(member) == module) && !(is(mixin(member)))) use static if (is(typeof(mixin(member))))
thanks Stanislav, that fixes the problem I encountered in particular. Generally speaking the issue is still valid. There's no way to detect that a member is a version identifier so using it this way: mixin("version(", member, ")"); is not possible.
@NilsLankila created dlang/dmd pull request #11255 "fix issue 20915 - add support for `is(identifier == version)`" fixing this issue: - fix issue 20915 - add support for `is(identifier == version)` This fills the small gap that existed because `__traits(allMembers)` could return the identifiers of the `VersionSymbol`s defined in the source but there was no way to identify them as such. https://github.com/dlang/dmd/pull/11255
__traits(allMembers) shouldn't be picking up version identifiers.
@NilsLankila created dlang/dmd pull request #11260 "fix issue 20915 - exclude version and debug identifier from `__traits(allMembers)` results" fixing this issue: - fix issue 20915 - exclude version and debug identifier from `__traits(allMembers)` results https://github.com/dlang/dmd/pull/11260
dlang/dmd pull request #11260 "fix issue 20915 - exclude version and debug identifier from `__traits(allMembers)` results" was merged into master: - fba63812c40ba01ff0c1fd09a238233a9eff9a90 by Nils Lankila: fix issue 20915 - exclude version and debug identifier from `__traits(allMembers)` results https://github.com/dlang/dmd/pull/11260
dlang/dmd pull request #12411 "[dmd-cxx] fix Issue 21813 - [REG-master] Bootstrap broken from dmd-cxx baseline" was merged into dmd-cxx: - 6dc21d3fcbee214b8aa73b707ad0e16236425c2c by Nils Lankila: [dmd-cxx] fix issue 20915 - exclude version and debug identifier from results https://github.com/dlang/dmd/pull/12411