3 modules are involved:
=== ast.d ===
module ast;
import symbol;
string astNodesClasses()
{
return "alias AstNodesSeq = AstNode;";
}
mixin(astNodesClasses());
alias AstNodes = AstNodesSeq;
string genVisitMethods(string statements)
{
return "void visit(" ~ AstNodes.stringof ~ "){}";
}
class AstNode{}
=== utils.d ====
module utils;
import ast, symbol;
class Foo
{
mixin(genVisitMethods(""));
}
=== symbol.d ===
module symbol;
import utils; // circular problem caused by this
================
compile with:
`dmd ast.d symbol.d utils.d -lib`
to get:
`ast.d(12): Error: undefined identifier AstNodesSeq
utils.d(8): called from here: genVisitMethods("")`
Now remove the import in symbol.d and try again, no problem, error is gone.
I think that there's should not be any circular issue.
In bigger project CTFE fails because of this (CTFE fails because of previous error in genVisit... etc)
Comment #1 by b2.temp — 2018-07-02T07:33:11Z
Add to this the quite unhelpful error message. Imagine the same problem drown in 5000 SLOCs. The only thing you see is that your declaration is here...
Comment #2 by robert.schadek — 2024-12-13T18:59:27Z