http://d.puremagic.com/issues/show_bug.cgi?id=7197
Summary: enum string doesn't work with CTFE Product: D Version: D2 Platform: Other OS/Version: Mac OS X Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: and...@metalanguage.com --- Comment #0 from Andrei Alexandrescu <and...@metalanguage.com> 2012-01-01 17:44:07 PST --- import std.stdio; string toConcatenatedForm(string m, string[] args...) { string result = "q{"; for (;;) { if (!m.length) { return result ~ '}'; } if (m[0] != '$') { result ~= m[0]; m = m[1 .. $]; continue; } if (m[1] >= '1' && m[1] <= '9') { result ~= "} ~ "; result ~= "expand!(q{" ~ args[m[1] - '1'] ~ "}) ~ q{"; m = m[2 .. $]; continue; } } } template expand(string m, args...) { enum string expand = mixin(toConcatenatedForm(m, args)); } unittest { enum string s = expand!("$1", "abc"); writeln(s); writeln(expand!("$1", s)); } void main(){} The code above causes an ICE: Assertion failed: (v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < stackPointer()), function setValue, file interpret.c, line 100. Replacing the first line in the unittest with static immutable string s = expand!("$1", "abc"); makes the code work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------