Bug ID | 170 |
---|---|
Summary | Template functions in templates missing member symbols |
Product | GDC |
Version | 4.8.x |
Hardware | All |
OS | All |
Status | NEW |
Severity | normal |
Priority | Normal |
Component | gdc |
Assignee | ibuclaw@gdcproject.org |
Reporter | obscurans@gmail.com |
Template functions in a template scope aren't inferring instantiations correctly. This is a bit hard to explain so here's a MWE: ---file1 module foobar; class bar(T) { void undefined_reference() {} } template foo(T) { bar!T foo1(T2)() if (true) body { return null; } bar!T foo2(T2)() { return null; } bar!T foo3(T2 = void)() if (true) body { return null; } bar!T foo4(T2 = void)() { return null; } void foo5(T2)(bar!T x) if (true) body {} void foo6(T2)(bar!T x) {} void foo7(T2 = void)(bar!T x) if (true) body {} void foo8(T2 = void)(bar!T x) {} } ---end ---file2 import foobar; void main() { foo!void.foo1!void(); // succeeds foo!void.foo2!void(); // succeeds foo!void.foo3(); // succeeds foo!void.foo3!void(); // succeeds foo!void.foo4(); // succeeds foo!void.foo4!void(); // succeeds // foo!void.foo5!void(null); // fails! foo!void.foo6!void(null); // succeeds foo!void.foo7(null); // succeeds // foo!void.foo7!void(null); // fails! foo!void.foo8(null); // succeeds foo!void.foo8!void(null); // succeeds } ---end Uncomment the failing lines, and I get (on 4.8.2) a linker error missing void foobar.bar!(void).bar.undefined_reference(). If they are in the same file nothing fails. For parameters only, it fails only if both a template argument was given and a template constraint exists.