DMD compiles the following code without complaining:
int templateFunction(A, B)(A a, B b);
From the spec: "FunctionLiterals and function templates, since their function bodies are always present, infer the pure, nothrow, and @safe attributes unless specifically overridden."
Either the complier or the spec is wrong. The current iteration of my grammar does not allow function bodies to be missing, since as far as I know, empty function templates are useless aside from forcing DDoc generation.
Comment #1 by maxim — 2013-07-05T03:29:14Z
Current implementation allows to split template declaration and template definition. You can place template declaration in .di file, full definition in .d file and instantiate template with specific arguments. In module, which imports .di file you can instantiate template if parameters match to those used in .d file (this is limitation as due to separate compilation it is impossible to know beforehand all potential parameters). Since instantiated function has no body, dmd issues reference to external symbol and the trick works (in such case compiler does not need template body but linker must find referenced symbols). This allows to hide template definitions in D at the cost of reducing potential possible parameters.
Comment #2 by briancschott — 2013-07-05T03:38:39Z
Makes sense. I'm removing "accepts-invalid" but leaving "spec". I'll have to update my parser and grammar.
Comment #3 by b2.temp — 2017-02-26T03:28:41Z
It seems you have updated libdparse for this since a while. No more errors.