Thread overview
filter custom version id from __traits code
Jun 09, 2020
Basile B.
Jun 09, 2020
Stanislav Blinov
Jun 09, 2020
Basile B.
June 09, 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 ?
June 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))))
June 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:
>
>> 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))))

Yes thanks again for the help.