digitalmars.D.bugs - [Issue 7348] New: to!string(null) matches more than one template declaration
- d-bugmail puremagic.com (28/28) Jan 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (14/14) Jan 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (13/13) Jan 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (10/10) Jan 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (10/10) Apr 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (24/25) Apr 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (8/9) Apr 19 2012 Seriously, this doesn't make any sense. It's always possible to break t...
- d-bugmail puremagic.com (13/13) Apr 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (13/13) May 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (8/8) May 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (24/26) May 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (23/23) May 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (7/7) May 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (7/7) May 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (13/13) May 28 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
- d-bugmail puremagic.com (9/9) May 31 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7348
http://d.puremagic.com/issues/show_bug.cgi?id=7348 Summary: to!string(null) matches more than one template declaration Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: trivial Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: alienballance gmail.com --- Comment #0 from Mariusz Gliwiński <alienballance gmail.com> 2012-01-22 09:56:28 PST --- import std.conv; void main() { to!string(null); } /usr/include/d/std/conv.d(237): Error: template std.conv.toImpl(T,S) if (isImplicitlyConvertible!(S,T)) toImpl(T,S) if (isImplicitlyConvertible!(S,T)) matches more than one template declaration, /usr/include/d/std/conv.d(245):toImpl(T,S) if (isImplicitlyConvertible!(S,T)) and /usr/include/d/std/conv.d(924):toImpl(T,S) if (is(S : Object) && isSomeString!(T)) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg gmx.com --- Comment #1 from Jonathan M Davis <jmdavisProg gmx.com> 2012-01-22 16:48:29 PST --- While I can see wanting this to work, I'm not sure how it could. What type is null? Is it string? A wstring? An int[]? An Object? If so, is it an Object or a class derived from Object? Etc. And if what you want is a null string, then just assign null to the string. What are you trying to do here? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #2 from Mariusz Gliwiński <alienballance gmail.com> 2012-01-23 11:58:31 PST --- [quote]What are you trying to do here?[/quote] void test(A)(A param) { writeln("A(",text(param),") called"); } void main() { test(null); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 23 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #3 from Jonathan M Davis <jmdavisProg gmx.com> 2012-01-23 13:49:20 PST --- Yeah. That doesn't really make sense. null could be anything that's null. And what type that is completely changes how text is instantiated. If you cast null to the type that you want, then it'll work. But null is its own type. You can't really do anything with null on its own like that. It needs be a null _something_, not just null. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 23 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 SomeDude <lovelydear mailmetrash.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lovelydear mailmetrash.com --- Comment #4 from SomeDude <lovelydear mailmetrash.com> 2012-04-19 09:55:21 PDT --- Should we close ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #5 from bearophile_hugs eml.cc 2012-04-19 15:07:52 PDT --- (In reply to comment #4)Should we close ?Don't close unless it's really unfixable in some way. Maybe "void*" is an acceptable textual output for this. --------------------- Related: import std.stdio; void main() { writeln(null); } DMD 2.059 shows: ...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'length' ...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'ptr', did you mean 'template tr(C1,C2,C3,C4 = immutable(char))'? test.d(3): Error: template instance std.stdio.writeln!(typeof(null)) error instantiating -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #6 from SomeDude <lovelydear mailmetrash.com> 2012-04-19 15:52:44 PDT ---Don't close unless it's really unfixable in some way.Seriously, this doesn't make any sense. It's always possible to break the language with stupid examples like this. This is a waste of time and resources. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 Vladimir Panteleev <thecybershadow gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow gmail.com --- Comment #7 from Vladimir Panteleev <thecybershadow gmail.com> 2012-04-19 16:01:56 PDT --- I think this bug is valid. text(null) should be equal to "null". I don't see how this falls under "breaking the language". The OP posted a plausible use case (logging the calls to a templated function), so calling this "stupid" is a bit over the line. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #8 from Kenji Hara <k.hara.pg gmail.com> 2012-05-12 09:22:49 PDT --- Now to!string(null) returns cast(string)null. Because null is implicitly convertible to string. Unit-test only: https://github.com/D-Programming-Language/phobos/pull/575 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 12 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #9 from github-bugzilla puremagic.com 2012-05-22 12:40:00 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/2e3d877f769abcf6ea0a9c6a31902b8cbd02ba75 fix Issue 7348 - to!string(null) matches more than one template declaration -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #10 from bearophile_hugs eml.cc 2012-05-22 13:54:53 PDT --- Now this code: import std.conv, std.stdio; void main() { writeln(">", to!string(null), "<"); } Prints:<But I expect something similar to:null<------------------------- This code: import std.stdio; void main() { writeln(null); } gives: ...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'length' ...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'ptr', did you mean 'template tr(C1,C2,C3,C4 = immutable(char))'? test.d(3): Error: template instance std.stdio.writeln!(typeof(null)) error instantiating -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #11 from Kenji Hara <k.hara.pg gmail.com> 2012-05-22 20:45:57 PDT --- (In reply to comment #10) [snip] OK. I found a good reason why we should select "null" as representation of null literal instead of "". Now,, to!string(something) is forwarded to formatValue(w, something, fmtspec). If we select "" (empty string) as the representation, "" should be able to *unformat* as null lietral. But, 0 length input matches everywhere. Then we would be able to unformat null value every time. string input = ""; typeof(null) nullvalue; formattedRead(input, "%s", &nullvalue); // read null value from empty input formattedRead(input, "%s", &nullvalue); // ditto formattedRead(input, "%s", &nullvalue); // ditto // can repeat infinitely... This is obviously strange. Then we should select a representation for null value which has one or more length string. So "null" is the best representation for the typeof(null) in D. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #12 from Vladimir Panteleev <thecybershadow gmail.com> 2012-05-22 20:47:58 PDT --- I agree. I think this behavior is also more useful to the use case in OP's example (logging). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #13 from Kenji Hara <k.hara.pg gmail.com> 2012-05-22 21:11:57 PDT --- to!string(null) should be equal to "null": https://github.com/D-Programming-Language/phobos/pull/599 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #14 from github-bugzilla puremagic.com 2012-05-28 11:18:06 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f5ccd7fdab3272e892f4685bab9cbf9e81eda0bd Retry to fix Issue 7348 - Format and unformat typeof(null) objects properly We should represent null literal as "null" instead of "" in formatting, because unformatting requires one or more length string representation of the object. https://github.com/D-Programming-Language/phobos/commit/61947e5fef8d3858dfa9b926e23f9e27517a5ebd Merge pull request #599 from 9rnsr/fix_nullfmt Issue 7348 & 8040 - null literal should be formatted as "null" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 28 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7348 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2012