filter custom version id from __traits code

Basile B. b2.temp at gmx.com
Tue Jun 9 17:40:10 UTC 2020


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: static

Any idea ?


More information about the Digitalmars-d-learn mailing list