www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4910] New: [CTFE] Cannot evaluate a function that has failed at once

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

           Summary: [CTFE] Cannot evaluate a function that has failed at
                    once
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rsinfu gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu gmail.com> 2010-09-21 15:33:40 PDT
---
If the interpretor failed to evaluate a function with an invalid argument at
once, then it fails to evaluate the same function with a valid argument.

The following code fails (it should succeed):
-------------------- test1.d
int echo(int a)
{
    return a;
}

template ctfe(int v) { }
static int var;
static assert(!__traits(compiles, ctfe!(echo(var)) ));

enum c = echo(123); // (10)
--------------------
% dmd -o- -c test1.d
test1.d(10): Error: cannot evaluate echo(123) at compile time
test1.d(10): Error: cannot evaluate echo(123) at compile time
--------------------

But it succeeds if echo(123) is evaluated before the failure.
-------------------- test2.d
int echo(int a)
{
    return a;
}

enum c = echo(123);

template ctfe(int v) { }
static int var;
static assert(!__traits(compiles, ctfe!(echo(var)) ));
--------------------
% dmd -o- -c test2.d
% _
--------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4910


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


--- Comment #1 from Don <clugdbug yahoo.com.au> 2011-05-18 21:18:24 PDT ---
D2 fix:
https://github.com/D-Programming-Language/dmd/commit/a316552c8f22d1865eeee10887def3c1cb2460bf

D1:
https://github.com/D-Programming-Language/dmd/commit/669cafeb9fecc98d5f4689f379f638a9661f0b35

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


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #2 from Don <clugdbug yahoo.com.au> 2011-06-07 01:23:06 PDT ---
*** Issue 5606 has been marked as a duplicate of this issue. ***

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