www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - An unexpected string to int exception.

reply Taylor Hillegeist <taylorh140 gmail.com> writes:
I think the following error message says it all.

std.conv.ConvException C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(2002):
Unexpected '1' when converting from type string to type int

I would expect that 1 would be among the group of expected items.
Feb 17 2016
parent reply Taylor Hillegeist <taylorh140 gmail.com> writes:
On Wednesday, 17 February 2016 at 16:11:44 UTC, Taylor Hillegeist 
wrote:
 I think the following error message says it all.

 std.conv.ConvException C:\D\dmd2\windows\bin\..\..\src\phob
s\std\conv.d(2002): Unexpected '1' when converting from type string to type int

 I would expect that 1 would be among the group of expected 
 items.
Also how rude of me: DMD32 D Compiler v2.070.0 code segment in question +++++ if(l.style.canFind("Heading")){ string tmp = l.style[6..$]; ON.incrementNum( to!int(tmp)); +++++
Feb 17 2016
parent reply Taylor Hillegeist <taylorh140 gmail.com> writes:
On Wednesday, 17 February 2016 at 16:13:47 UTC, Taylor Hillegeist 
wrote:
 On Wednesday, 17 February 2016 at 16:11:44 UTC, Taylor 
 Hillegeist wrote:
 I think the following error message says it all.

 std.conv.ConvException C:\D\dmd2\windows\bin\..\..\src\phob
s\std\conv.d(2002): Unexpected '1' when converting from type string to type int

 I would expect that 1 would be among the group of expected 
 items.
Also how rude of me: DMD32 D Compiler v2.070.0 code segment in question +++++ if(l.style.canFind("Heading")){ string tmp = l.style[6..$]; ON.incrementNum( to!int(tmp)); +++++
So my error here was i was slicing too early. string tmp = l.style[6..$]; should have been: string tmp = l.style[7..$]; apparently std.conv parse() will say the unexpected input is not the one that caused the error but the character after. in this case "g1" only the 1 was reported.
Feb 17 2016
parent reply "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Wed, Feb 17, 2016 at 04:38:34PM +0000, Taylor Hillegeist via
Digitalmars-d-learn wrote:
 On Wednesday, 17 February 2016 at 16:13:47 UTC, Taylor Hillegeist wrote:
On Wednesday, 17 February 2016 at 16:11:44 UTC, Taylor Hillegeist wrote:
I think the following error message says it all.

std.conv.ConvException C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(2002):
Unexpected '1' when converting from type string to type int

I would expect that 1 would be among the group of expected items.
Also how rude of me: DMD32 D Compiler v2.070.0 code segment in question +++++ if(l.style.canFind("Heading")){ string tmp = l.style[6..$]; ON.incrementNum( to!int(tmp)); +++++
So my error here was i was slicing too early. string tmp = l.style[6..$]; should have been: string tmp = l.style[7..$]; apparently std.conv parse() will say the unexpected input is not the one that caused the error but the character after. in this case "g1" only the 1 was reported.
Please file a bug, I'll look into making a fix for it. T -- Insanity is doing the same thing over and over again and expecting different results.
Feb 17 2016
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 02/17/2016 09:09 AM, H. S. Teoh via Digitalmars-d-learn wrote:

 apparently std.conv parse() will say the unexpected input is not the
 one that caused the error but the character after. in this case "g1"
 only the 1 was reported.
Please file a bug, I'll look into making a fix for it.
I shamefully admit that I've discovered this bug months ago and tampered with three error messages on the following page: :D http://ddili.org/ders/d.en/fibers.html For example, the 'h' below was typed by my own right-hand index finger. :) Error: Unexpected 'h' when converting from type string to type uint Ali
Feb 17 2016
parent reply "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Wed, Feb 17, 2016 at 10:44:40AM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
 On 02/17/2016 09:09 AM, H. S. Teoh via Digitalmars-d-learn wrote:
 
 apparently std.conv parse() will say the unexpected input is not
 the one that caused the error but the character after. in this case
 "g1" only the 1 was reported.
Please file a bug, I'll look into making a fix for it.
I shamefully admit that I've discovered this bug months ago and tampered with three error messages on the following page: :D http://ddili.org/ders/d.en/fibers.html For example, the 'h' below was typed by my own right-hand index finger. :) Error: Unexpected 'h' when converting from type string to type uint
[...] So where's the bug report?? ;-) T -- "Outlook not so good." That magic 8-ball knows everything! I'll ask about Exchange Server next. -- (Stolen from the net)
Feb 17 2016
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 02/17/2016 11:08 AM, H. S. Teoh via Digitalmars-d-learn wrote:

 For example, the 'h' below was typed by my own right-hand index
 finger. :)

    Error: Unexpected 'h' when converting from type string to type uint
[...] So where's the bug report?? ;-)
That's the shame part. :) I was so tired and trying to get things done, I've just changed three characters and moved on. Ali
Feb 17 2016
parent "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Wed, Feb 17, 2016 at 11:16:50AM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
 On 02/17/2016 11:08 AM, H. S. Teoh via Digitalmars-d-learn wrote:
 
 For example, the 'h' below was typed by my own right-hand index
 finger. :)

    Error: Unexpected 'h' when converting from type string to type uint
[...] So where's the bug report?? ;-)
That's the shame part. :) I was so tired and trying to get things done, I've just changed three characters and moved on.
[...] Sigh, nobody got my hint? Oh well, here goes: https://issues.dlang.org/show_bug.cgi?id=15695 And here's the fix: https://github.com/D-Programming-Language/phobos/pull/4008 T -- Fact is stranger than fiction.
Feb 17 2016