https://issues.dlang.org/show_bug.cgi?id=12571
--- Comment #5 from Kenji Hara <[email protected]> --- (In reply to Andrej Mitrovic from comment #3) > That doesn't work. It will return 'test' which is the module name rather > than 'main'. Oh, sorry. I didn't see the local execution result carefully. ---- I confirmed root problem. The opening code must not work. But, if the type of scopeName is explicitly specified, it should work. mixin template getScopeName() { // NG, circular reference to scopeName // enum scopeName = __traits(identifier, __traits(parent, scopeName)); // should be OK enum string scopeName = __traits(identifier, __traits(parent, scopeName)); } In original case, the type of scopeName is inferred from its initializer. Therefore on the evaluation of __traits(parent, scopeName), it will recursively invoke semantic analysis of the initialize, then it will cause forward reference. By adding variable type, the declaration and definition of scopeName variable will be properly separated. Therefore on __traits(parent, scopeName), it should not cause recursive semantic analysis of the initializer. Finally it should work as expected. ---- But, currently the code will cause ICE. It is definitely a compiler bug. I'll open a pull request to fix it. --
