www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22661] New: Functions cannot be interpreted while being

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

          Issue ID: 22661
           Summary: Functions cannot be interpreted while being compiled
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: tim.dlang t-online.de

//////////////////// parent.d /////////////////////
import childb;
import defs;
class Parent
{
    enum CONSTANT = defs.CONSTANT;
}
//////////////////// childa.d /////////////////////
import parent;
import helpers;
class ChildA : Parent
{
    mixin(ctfeFunc(true));
}
//////////////////// childb.d /////////////////////
import parent;
import helpers;
class ChildB : Parent
{
    mixin(ctfeFunc());
}
///////////////////// defs.d //////////////////////
import childa;
enum CONSTANT = "";
//////////////////// helpers.d ////////////////////
string ctfeFunc(bool)
{
    import std.ascii;
    return "";
}
string ctfeFunc()
{
    return ctfeFunc(false);
}
///////////////////////////////////////////////////

Compiling the above code with dmd -c parent.d results in the following error:
helpers.d(1): Error: function `helpers.ctfeFunc` circular dependency. Functions
cannot be interpreted while being compiled
childa.d(5):        called from here: `ctfeFunc(true)`
helpers.d(8):        called from here: `ctfeFunc(false)`
childb.d(5):        called from here: `ctfeFunc()`

--
Jan 09 2022