www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6954] New: std.conv.to!int doesn't work in CTFE

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

           Summary: std.conv.to!int doesn't work in CTFE
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com



11:39:54 PST ---
The reason it doesn't work is scope(exit).

Looking at the code[1], it doesn't look like the scope(exit) is really
necessary here (I don't see why it should catch exceptions thrown by parse), so
until there's scope(...) CTFE support, a simple fix would be to rewrite the
code as:

    auto result = parse!T(v);
    if (v.length)
        convError!(SV, T)(v);
    return result;

[1]:
https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L1606

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6954


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



Do you have a test case that doesn't work?
scope statements are supported in CTFE now.
This works on git DMD head:

import std.conv;
static assert(to!int("754") == 754);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 16 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6954


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



05:28:18 PST ---
Right, should have updated before reporting. Sorry for the noise.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 16 2011