Bug 19047 – Undefined identifier caused by circular import and CTFE

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-07-02T07:03:22Z
Last change time
2024-12-13T18:59:27Z
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#19453 →

Comments

Comment #0 by b2.temp — 2018-07-02T07:03:22Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19453 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB