https://issues.dlang.org/show_bug.cgi?id=23651
Issue ID: 23651
Summary: Order dependency in semantic analysis of template
members
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
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
--