digitalmars.D.bugs - Possible bug with mixin template functions and variadic params
- Derek Ney (37/37) Jul 24 2008 I posted the following the the language forum thinking perhaps I was doi...
- Jarrett Billingsley (5/51) Jul 24 2008 Don't be shy about making bug reports :) If something doesn't seem righ...
- Koroskin Denis (5/52) Jul 24 2008 Bugs should be posted to bugzilla: http://d.puremagic.com/issues/
I posted the following the the language forum thinking perhaps I was doing something wrong, but it seems that this may be a bug in the 2.014 compiler. Here is what I posted: I am trying to create a set of methods that take a variable number of arguments (at compile time). I would have liked to have used template functions to do that, but I need the functions to be virtual, and template functions cannot be virtual. So I thought I would try to use a mixin of a variadic template function. But I am getting a weird compiler error with my simple test program. Here is the test program: 1 import std.stdio; 2 3 template TCALL(ARGS...) 4 { 5 void makecall(ARGS args) 6 { 7 writefln("tcall...", args); 8 } 9 } 10 11 mixin TCALL!(); 12 mixin TCALL!(int); 13 mixin TCALL!(int,int); 14 15 16 class Method 17 { 18 mixin TCALL!(); 19 mixin TCALL!(int); 20 mixin TCALL!(int,int); 21 } 22 23 void main() 24 { 25 auto m = new Method; 26 27 m.makecall(0,1); 28 makecall(0,1); 29 } And when I compile with "Digital Mars D Compiler v2.014" I get this error: test6.d(27): Error: m.makecall is not a declaration test6.d(27): Error: function expected before (), not 1 of type int Can anyone explain what is going on here? It seems like it should work. Note that if you comment out line 27 and compile it compiles fine and runs producing the expected output: tcall...01 -Thanks, Derek
Jul 24 2008
"Derek Ney" <derek hipgraphics.com> wrote in message news:g69vng$1lt6$1 digitalmars.com...I posted the following the the language forum thinking perhaps I was doing something wrong, but it seems that this may be a bug in the 2.014 compiler. Here is what I posted: I am trying to create a set of methods that take a variable number of arguments (at compile time). I would have liked to have used template functions to do that, but I need the functions to be virtual, and template functions cannot be virtual. So I thought I would try to use a mixin of a variadic template function. But I am getting a weird compiler error with my simple test program. Here is the test program: 1 import std.stdio; 2 3 template TCALL(ARGS...) 4 { 5 void makecall(ARGS args) 6 { 7 writefln("tcall...", args); 8 } 9 } 10 11 mixin TCALL!(); 12 mixin TCALL!(int); 13 mixin TCALL!(int,int); 14 15 16 class Method 17 { 18 mixin TCALL!(); 19 mixin TCALL!(int); 20 mixin TCALL!(int,int); 21 } 22 23 void main() 24 { 25 auto m = new Method; 26 27 m.makecall(0,1); 28 makecall(0,1); 29 } And when I compile with "Digital Mars D Compiler v2.014" I get this error: test6.d(27): Error: m.makecall is not a declaration test6.d(27): Error: function expected before (), not 1 of type int Can anyone explain what is going on here? It seems like it should work. Note that if you comment out line 27 and compile it compiles fine and runs producing the expected output: tcall...01 -Thanks, DerekDon't be shy about making bug reports :) If something doesn't seem right to you -- file it! Even if it isn't a bug, you'll at least get (or have a chance at getting) it looked at, responded to, and possibly changed.
Jul 24 2008
On Thu, 24 Jul 2008 17:22:56 +0400, Derek Ney <derek hipgraphics.com> wrote:I posted the following the the language forum thinking perhaps I was doing something wrong, but it seems that this may be a bug in the 2.014 compiler. Here is what I posted: I am trying to create a set of methods that take a variable number of arguments (at compile time). I would have liked to have used template functions to do that, but I need the functions to be virtual, and template functions cannot be virtual. So I thought I would try to use a mixin of a variadic template function. But I am getting a weird compiler error with my simple test program. Here is the test program: 1 import std.stdio; 2 3 template TCALL(ARGS...) 4 { 5 void makecall(ARGS args) 6 { 7 writefln("tcall...", args); 8 } 9 } 10 11 mixin TCALL!(); 12 mixin TCALL!(int); 13 mixin TCALL!(int,int); 14 15 16 class Method 17 { 18 mixin TCALL!(); 19 mixin TCALL!(int); 20 mixin TCALL!(int,int); 21 } 22 23 void main() 24 { 25 auto m = new Method; 26 27 m.makecall(0,1); 28 makecall(0,1); 29 } And when I compile with "Digital Mars D Compiler v2.014" I get this error: test6.d(27): Error: m.makecall is not a declaration test6.d(27): Error: function expected before (), not 1 of type int Can anyone explain what is going on here? It seems like it should work. Note that if you comment out line 27 and compile it compiles fine and runs producing the expected output: tcall...01 -Thanks, DerekBugs should be posted to bugzilla: http://d.puremagic.com/issues/ This newsgroup is just mirroring posted bug reports and used for bug discussion that should not go to bugzilla for some reason.
Jul 24 2008