digitalmars.D.bugs - [Issue 10841] New: std.conv.parse failed when parsing a slice string
- d-bugmail puremagic.com (22/22) Aug 17 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10841
- d-bugmail puremagic.com (15/15) Aug 17 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10841
- d-bugmail puremagic.com (18/18) Aug 17 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10841
http://d.puremagic.com/issues/show_bug.cgi?id=10841 Summary: std.conv.parse failed when parsing a slice string Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bitworld qq.com The test code is here: //============= string s1 = "11AB"; auto r = parse!int(s1[0..2], 16); //============= It worked with DMD 2.062, but failed with DMD 2.063.2. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10841 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |jmdavisProg gmx.com Resolution| |INVALID PDT --- If it worked with 2.062, it was a bug. parse accepts its argument by ref (because it alters the argument by popping characters off of it as they're parsed), which means that the argument must be an lvalue, and a slice is not an lvalue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10841 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 18:51:09 PDT --- The rationale of the change is in the changelog: http://dlang.org/changelog.html#sliceref As a workaround you'll have to assign s1[0..2] to another variable and pass it to parse. A better alternative is to use to!() instead of parse!(): string s1 = "11AB"; auto r = to!int(s1[0..2], 16); There /was/ some brief discussion about making parse work with slices as well, since it could be considered convenient (and would avoid code breakage), but there was no outcome for the 2.063 release. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2013