[Issue 15419] New: std.conv.parse() does not accept string literals

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Dec 7 16:32:46 PST 2015


https://issues.dlang.org/show_bug.cgi?id=15419

          Issue ID: 15419
           Summary: std.conv.parse() does not accept string literals
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: thomas.bockman at gmail.com

>From the std.conv.parse() unittests:

    // @@@BUG@@@ the size of China
        // foreach (i; 2..37)
        // {
        //      assert(parse!int("0",i) == 0);
        //      assert(parse!int("1",i) == 1);
        //      assert(parse!byte("10",i) == i);
        // }
        foreach (i; 2..37)
        {
            string s = "0";
                assert(parse!int(s,i) == 0);
            s = "1";
                assert(parse!int(s,i) == 1);
            s = "10";
                assert(parse!byte(s,i) == i);
        }
    // Same @@@BUG@@@ as above
        //assert(parse!int("0011001101101", 2) == 0b0011001101101);
        // assert(parse!int("765",8) == 0765);
        // assert(parse!int("fCDe",16) == 0xfcde);
    auto s = "0011001101101";
        assert(parse!int(s, 2) == 0b0011001101101);
    s = "765";
        assert(parse!int(s, 8) == octal!765);
    s = "fCDe";
        assert(parse!int(s, 16) == 0xfcde);

This is caused by `parse()` using pass-by-ref for the first argument, which
does not support rvalues since `scope ref` isn't implemented yet.

--


More information about the Digitalmars-d-bugs mailing list