Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
February 17, 2016 An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
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. |
February 17, 2016 Re: An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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)); +++++ |
February 17, 2016 Re: An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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.
|
February 17, 2016 Re: An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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. |
February 17, 2016 Re: An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | 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 |
February 17, 2016 Re: An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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) |
February 17, 2016 Re: An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | 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 |
February 17, 2016 Re: An unexpected string to int exception. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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. |
Copyright © 1999-2021 by the D Language Foundation