Bug 7590 – no error with missing template parameter

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-26T07:34:00Z
Last change time
2012-02-26T08:50:30Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
hoganmeier

Comments

Comment #0 by hoganmeier — 2012-02-26T07:34:57Z
template curry(alias fun, alias arg) { auto curry(Ts args2) { return fun(arg, args2); } } unittest { static struct TCallable { auto opCall(A, )(A a, B b) { return a + b; } } TCallable tcallable; static assert(!is(typeof(curry!(tcallable, "5")))); } $ dmd -c -unittest test.d
Comment #1 by hoganmeier — 2012-02-26T07:35:38Z
NB: The problem is B isn't defined.
Comment #2 by k.hara.pg — 2012-02-26T07:57:46Z
D parser simply ignores almost of unnecessary last comma in list like follows. enum E { A = 0, B, C, } // last comma is ignored void func(int x, int y, ){} // last comma is ignored //template X((T, U, ){} // this cannot pass parsing... void tfunc(A, B, )(A, B){}; // last comma is ignored void main() { func(1,2); // func has two parameters tfunc(1,2); // tfunc has two parameters } Then, > auto opCall(A, )(A a, B b) in struct TCallable is valid template function declaration, same as auto opCall(A)(A a, B b) But B is undefined identifier, so its instantiation fails inside is(typeof(...)).
Comment #3 by hoganmeier — 2012-02-26T08:50:30Z
Ah yep, forgot that the error is gagged.