Consider, reduced from
https://github.com/jmdavis/dxml/blob/d8eb8cff883d78a6258fc1e829484262c6f009fb/source/dxml/parser.d#L3628 :
---
template isCallable(alias callable)
{
static if (is(typeof(&callable!())))
enum bool isCallable = isCallable!(typeof(&callable!()));
else
enum bool isCallable = true;
}
string foo();
template FunctionTypeOf(alias func)
if (isCallable!func)
{
alias FunctionTypeOf = typeof(foo);
}
template ReturnType(alias func)
{
static if (is(FunctionTypeOf!func R == return))
alias ReturnType = R;
}
template isAttrRange(R)
{
alias NameType = ReturnType!((R r) => r);
pragma(msg, is(NameType == string)); // prints true
enum isAttrRange = is(NameType == string);
}
static assert(isAttrRange!string); // fails
---
The trouble boils down to `enum isAttrRange` being evaluated before `NameType` is, so the `is(NameType == string)` fails.
This is a blocker for https://github.com/dlang/dmd/pull/14838
Comment #1 by bugzilla — 2023-01-23T23:21:19Z
aliasdecl is set to isAttrRange.
updateTemplate() calls aliasdecl->toAlias(), where the semantic for aliasdecl gets called, which fails, because semantic for NameType hasn't been called yet.
The semantic for the NameType definition should be called in resolveHelper(), but my attempts to call it there result in more problems.
Making this problem a separate issue should allow focus on it.
Comment #2 by dlang-bot — 2023-01-24T06:17:01Z
@WalterBright updated dlang/dmd pull request #14843 "AliasDeclaration semantic" fixing this issue:
- fix Issue 23651 - Order dependency in semantic analysis of template members
https://github.com/dlang/dmd/pull/14843
Comment #3 by dlang-bot — 2023-01-25T00:32:45Z
dlang/dmd pull request #14843 "fix Issue 23651 - Order dependency in semantic analysis of template members" was merged into master:
- 76a5cc4866d4542f42daae22e4cb1d03f1c659b2 by Walter Bright:
fix Issue 23651 - Order dependency in semantic analysis of template members
https://github.com/dlang/dmd/pull/14843