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



---
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



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



*** 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