D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7590 - no error with missing template parameter
Summary: no error with missing template parameter
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2012-02-26 07:34 UTC by Trass3r
Modified: 2012-02-26 08:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Trass3r 2012-02-26 07:34:57 UTC
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 Trass3r 2012-02-26 07:35:38 UTC
NB: The problem is B isn't defined.
Comment 2 Kenji Hara 2012-02-26 07:57:46 UTC
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 Trass3r 2012-02-26 08:50:30 UTC
Ah yep, forgot that the error is gagged.