https://issues.dlang.org/show_bug.cgi?id=15730
Issue ID: 15730 Summary: invalid template merging in tuple foreach Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: ket...@ketmar.no-ip.org the following code fails with "Error: function pointer arg () is not callable using argument types (Object)" void selector(A...) (Object o, scope A args) { import std.traits : arity; foreach (immutable aidx, arg; args) { static if (arity!arg == 0) arg(); else arg(o); } } void main () { selector(new Object, (Object o) {}, () {} ); } but if one will change static if line to this: static if (arity!(args[aidx]) == 0) arg(); else arg(o); everything is working right. the bug is that frontend doesn't differentiate between template instantiations in unrolled `foreach` loop, and merges all `arity` instantiations to the first one, which returns `1`. compiler should either reject such code, or stop merging templates if there is `foreach` arg used to make an instance. --