digitalmars.D - moduleName bug
- JS (30/30) Jul 12 2013 Module name doesn't seem to work with qualified module names. I
Module name doesn't seem to work with qualified module names. I imagine this also is an issue with other similar functions: template moduleName(alias T) { static assert(!T.stringof.startsWith("package "), "cannot get the module name for a package"); static if (T.stringof.startsWith("module ")) { static if (__traits(compiles, packageName!T)) enum packagePrefix = packageName!T ~ '.'; else enum packagePrefix = ""; enum moduleName = packagePrefix ~ T.stringof[7..$]; } else alias moduleName!(__traits(parent, T)) moduleName; } The error I get is about circular references on moduleName. The code that produces the error is: template test(alias i) { alias typeof(i) I; pragma(msg, "import "~moduleName!(I)~"."~I.stringof~";"); } this code seems to work fine in a simple environment but in my code it doesn't as I get that error. I've tried reducing my code to the most simplest but still get the error. I'm sure there is something wrong with the moduleName... possibly the static if statement isn't enough to ensure termination of the recursion? (does "module my.module" start with "module" or "my"?)
Jul 12 2013