D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9894 - Member func of templated struct can't pass varargs to templated member func
Summary: Member func of templated struct can't pass varargs to templated member func
Status: RESOLVED DUPLICATE of issue 9885
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-04-06 19:34 UTC by Nick Sabalausky
Modified: 2015-06-09 01:31 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 Nick Sabalausky 2013-04-06 19:34:17 UTC
struct Foo(TArgs...) {
     void func(TArgs args) { func2(args); }
     void func2()(TArgs args) {}
}

void main() {
     Foo!(int).func(5);
}

DMD output:
test.d(2): Error: template test.Foo!(int).Foo.func2 does not match any function template declaration. Candidates are:
test.d(3):        test.Foo!(int).Foo.func2()(TArgs args)
test.d(2): Error: template test.Foo!(int).Foo.func2()(TArgs args) cannot deduce template function from argument types !()(int)
test.d(7): Error: template instance test.Foo!(int) error instantiating
Comment 1 Nick Sabalausky 2013-04-06 19:36:59 UTC
Note that if func2 is *NOT* a template, then it works.
Comment 2 Nick Sabalausky 2013-04-06 19:45:48 UTC
Workaround:

struct Foo(TArgs...) {
    void func(TArgs args) { this.workaround(args); }
    void func2()(TArgs args) {}
}
void workaround(Struct, TArgs...)(Struct s, TArgs args)
{
    s.func2!()(args);
}

void main() {
    Foo!(int) f;
    f.func(5);
}
Comment 3 Kenji Hara 2013-04-07 02:19:47 UTC

*** This issue has been marked as a duplicate of issue 9885 ***