January 05, 2013 Is this a known issue in Phobos/DMD? | ||||
---|---|---|---|---|
| ||||
Attachments:
| Greetings When I compile the code below, I unexpectedly get an error: test.d(7): Error: template std.string.format does not match any function template declaration. Candidates are: /home/puneet/local/github-d/bin/../phobos/std/string.d(2528): std.string.format(Char, Args...)(in Char[] fmt, Args args) test.d(7): Error: template std.string.format(Char, Args...)(in Char[] fmt, Args args) cannot deduce template function from argument types !()(string,void) There are a couple of issues involved here. 1. std.string is exposing "count" (and some other functions) from std.algorithm. I think this should be a bug since count is not listed as a method in the std.string documentation. 2. Now the function from std.algorithm that becomes visible, shadows the local argument count. Is this expected behavior? If not, has it already been reported as a bug? At the minimum I expect better error message here. Thanks and Regards - Puneet void main() { // 1 foo(4); // 2 } // 3 // 4 void foo(int count) { // 5 import std.string; // 6 format("%s", count); // 7 } // 8 |
January 06, 2013 Re: Is this a known issue in Phobos/DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to d coder | On 01/05/2013 05:09 PM, d coder wrote: > Greetings > > When I compile the code below, I unexpectedly get an error: > test.d(7): Error: template std.string.format does not match any function > template declaration. Candidates are: > /home/puneet/local/github-d/bin/../phobos/std/string.d(2528): > std.string.format(Char, Args...)(in Char[] fmt, Args args) > test.d(7): Error: template std.string.format(Char, Args...)(in Char[] > fmt, Args args) cannot deduce template function from argument types > !()(string,void) > > There are a couple of issues involved here. > 1. std.string is exposing "count" (and some other functions) from > std.algorithm. I think this should be a bug since count is not listed as > a method in the std.string documentation. > 2. Now the function from std.algorithm that becomes visible, shadows the > local argument count. Is this expected behavior? If not, has it already > been reported as a bug? At the minimum I expect better error message here. > > Thanks and Regards > - Puneet > > > void main() { // 1 > foo(4); // 2 > } // 3 > // 4 > void foo(int count) { // 5 > import std.string; // 6 > format("%s", count); // 7 > } // 8 > I think it is a bug, but there is no documentation. http://d.puremagic.com/issues/show_bug.cgi?id=7329 The part about count is caused by Phobos. (from std.string: //Remove when repeat is finally removed. They're only here as part of the //deprecation of these functions in std.string. public import std.algorithm : startsWith, endsWith, cmp, count; ) |
Copyright © 1999-2021 by the D Language Foundation