digitalmars.D.learn - filter custom version id from __traits code
- Basile B. (29/34) Jun 09 2020 I don't see how to filter a custom version identifier from this
- Stanislav Blinov (2/10) Jun 09 2020
- Basile B. (2/13) Jun 09 2020 Yes thanks again for the help.
I don't see how to filter a custom version identifier from this traits code: --- 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(), "this script must hide globals as local static variable in a getter"); void main(){} ---: Error: undefined identifier my_version in module test onlineapp.d(12): Error: module test.my_version cannot be resolved onlineapp.d(21): called from here: onlyFuncs() onlineapp.d(21): while evaluating: staticAny idea ?
Jun 09 2020
On Tuesday, 9 June 2020 at 17:40:10 UTC, Basile B. wrote:Any idea ?As I replied in the issue report:Instead of static if (!is(mixin(member) == module) && !(is(mixin(member)))) use static if (is(typeof(mixin(member))))
Jun 09 2020
On Tuesday, 9 June 2020 at 18:08:01 UTC, Stanislav Blinov wrote:On Tuesday, 9 June 2020 at 17:40:10 UTC, Basile B. wrote:Yes thanks again for the help.Any idea ?As I replied in the issue report:Instead of static if (!is(mixin(member) == module) && !(is(mixin(member)))) use static if (is(typeof(mixin(member))))
Jun 09 2020