https://issues.dlang.org/show_bug.cgi?id=16608
Issue ID: 16608
Summary: 'static foreach', local function template, 'static
if', anySatisfy: Only the first iteration seems to
work
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
import std.meta;
void main() {
foreach (s; AliasSeq!("a", "b")) {
// The problem is that this function is called only for the "a"
iteration
bool condition(string x)() {
pragma(msg, "comparing ", x, " and ", s);
return x == s;
}
// This condition is expected to be true for the "b" iteration
static if (anySatisfy!(condition, AliasSeq!("b"))) {
pragma(msg, "yes for ", s);
}
else {
pragma(msg, "NO for ", s);
}
}
}
However, the condition() is called only for "a" and we get "NO" for the "b"
iteration as well:
comparing b and a
NO for a
NO for b <-- Why didn't we get "comparing b and b" before this?
Ali
--