www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8231] New: conv.to fails to convert string with trailing "u"

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8231

           Summary: conv.to fails to convert string with trailing "u"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



18:36:57 PDT ---
import std.conv;

void main()
{
    uint x = 3u;  // ok
    uint y = to!uint("3u");  // fail
}

std.conv.ConvException D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(1597):
Unexpected 'u' when converting from type string to type uint

If it can be used in D syntax it should be convertible by conv.to.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 11 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8231




Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/9f5c180b667faa512dac2e01dff19490688c07ac
Disable test for bug 8231 temporarily.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8231


John Colvin <john.loughran.colvin gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.loughran.colvin gmail.
                   |                            |com



23:21:56 BST ---
This is quite easily fixed with a little utility function that checks if the
remainder after parsing is a floating point or integer suffix.

However, it is potentially a nasty subtle breaking change as it's quite a
common pattern to rely on functions like "to" to check for unusual input, which
this would change the definition of. It also introduces a difference in
attitude between "to" and "parse", which currently work together very neatly.

On those grounds, I'm against it.

To be acceptable it would have to be enabled with a template argument (an enum
with names RAW and D_LITERAL_AWARE ?), or be in a function with a different
name.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 17 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8231


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



Both converting regular numbers and converting D literals to their values are
important needs and use cases, but mixing them transparently is probably a not
so good idea.

So better to give it a different function name or to add some compile-time


D number literals also allow underscores: 1_000_000u

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 17 2013