[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 --- Comment #8 from Jonathan M Davis 2012-07-10 14:10:53 PDT --- See also bug# 8373 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 Kenji Hara changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|INVALID | --- Comment #7 from Kenji Hara 2012-06-29 22:14:10 PDT --- (In reply to comment #6) > > I think you might have missed the second set of parentheses on the first > template function declaration. > > Ah, you're right. I did miss those, but it still shouldn't compile, because > the > compiler doesn't know which template the programmer was trying to instantiate. > Did they mean the first one (which would then be callable) or the second > (which > wouldn't, because it lacks the function arguments that it requires). The > template functions don't even exist to be checked for overloading rules until > they've been instantiated, so overloading rules have no effect here. Remember > that they actually translate to > [snip] > > So, when you say lol!"rulez", which one is the compiler going to pick? It > doesn't know which you mean. The template signatures are identical and have no > template constraints to distinguish them. So, you have a conflict. I think it should be compile. In D language, template functions, that is a template contains one function declaration, is specially treated in its call, and it is priority than normal template lookup/instantiation rule. In this case, compiler knows the the two lol's are template functions, so such special rule should be applied. In current dmd without -property switch, lol!"rulez" should be implicitly converted to lol!"rulez"(), and matches to the first declaration of lol. Furthermore says, even if you add @property and use -property, following code doesn't work. @property void lol(string wat) () { writeln(wat); } @property void lol(string wat) (string omg) { writeln(wat, " ", omg); } void main() { lol!"rulez";// should call the first lol!"rulez" = "xxx";// should call the second } test.d(13): Error: template test.lol matches more than one template declaration, test.d(3):lol(string wat) and test.d(7):lol(string wat) test.d(14): Error: template test.lol matches more than one template declaration, test.d(3):lol(string wat) and test.d(7):lol(string wat) It seems to me that is definitely correct code, but if we make this issue invalid, such property overloading would also become 'invalid'. I cannot accept it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 --- Comment #6 from Jonathan M Davis 2012-06-29 17:01:10 PDT --- > I think you might have missed the second set of parentheses on the first template function declaration. Ah, you're right. I did miss those, but it still shouldn't compile, because the compiler doesn't know which template the programmer was trying to instantiate. Did they mean the first one (which would then be callable) or the second (which wouldn't, because it lacks the function arguments that it requires). The template functions don't even exist to be checked for overloading rules until they've been instantiated, so overloading rules have no effect here. Remember that they actually translate to template lol(string wat) { void lol() { writeln(wat); } } template lol(string wat) { void lol(string omg) { writeln(wat, " ", omg); } } So, when you say lol!"rulez", which one is the compiler going to pick? It doesn't know which you mean. The template signatures are identical and have no template constraints to distinguish them. So, you have a conflict. If you did template lol(string wat) { void lol() { writeln(wat); } void lol(string omg) { writeln(wat, " ", omg); } } then it would work (assuming that you didn't compile with -property, since then you'd have to do lol!"rulez"() rather than lol!"rulez", since the lol function isn't a property). But with how they're currently declared, you have a conflict between two templates. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 --- Comment #5 from meh. 2012-06-29 16:50:31 PDT --- Both are template functions. The first is a template function without arguments, the second has one. I'm calling the first. It throws a dumb error when it's clear what I want to do. It's code that worked before. It's a regression. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 --- Comment #4 from timon.g...@gmx.ch 2012-06-29 16:47:38 PDT --- (In reply to comment #3) > > Isn't it a function call where the parens were left out? > > It would be if the functions didn't have any parameters, but they both do, so > I > don't know quite what the compiler thinks that it is. > > Regardless, lol!"rulez" results in a function named lol which takes a single > string argument when there's already such a function (albeit non-templated) > which exists. It's clearly a conflict no matter what you're trying to do with > it. I think you might have missed the second set of parentheses on the first template function declaration. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 Jonathan M Davis changed: What|Removed |Added CC||jmdavisp...@gmx.com --- Comment #3 from Jonathan M Davis 2012-06-29 16:45:53 PDT --- > Isn't it a function call where the parens were left out? It would be if the functions didn't have any parameters, but they both do, so I don't know quite what the compiler thinks that it is. Regardless, lol!"rulez" results in a function named lol which takes a single string argument when there's already such a function (albeit non-templated) which exists. It's clearly a conflict no matter what you're trying to do with it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 timon.g...@gmx.ch changed: What|Removed |Added CC||timon.g...@gmx.ch --- Comment #2 from timon.g...@gmx.ch 2012-06-29 16:25:29 PDT --- Isn't it a function call where the parens were left out? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8316] Regression with template functions
http://d.puremagic.com/issues/show_bug.cgi?id=8316 Walter Bright changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||INVALID --- Comment #1 from Walter Bright 2012-06-29 15:19:52 PDT --- It does match both. Not sure what you expect it to do. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---