http://d.puremagic.com/issues/show_bug.cgi?id=8714
Summary: Instantiate template within CTFE with same CTFE returned value Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: jens.k.muel...@gmx.de --- Comment #0 from jens.k.muel...@gmx.de 2012-09-23 14:08:29 PDT --- To better integrate CTFE and templates it may be worthwhile to allow code as follows string foo(string f) { if (f == "somestring") { return "got somestring"; } return bar!(foo("somestring")); } template bar(string s) { enum bar = s; } Note, that the return value of foo("somestring") is "got somestring" which should be possible to pass to some template. Code like string foo(string f) { if (f == "somestring") { return "got somestring"; } return bar!(foo("somestring"))(); } string bar(string s)() { return s; } should compile as well. Both fail with dmd 2.060. The first code fails with: test.d(7): called from here: foo("somestring") test.d(7): called from here: foo("somestring") test.d(7): called from here: foo("somestring") test.d(7): Error: expression foo("somestring") is not a valid template value argument test.d(12): called from here: foo("somestring") test.d(12): called from here: foo("somestring") test.d(7): Error: template instance test.bar!(foo("somestring")) error instantiating and the second with: test.d(7): called from here: foo("somestring") test.d(7): called from here: foo("somestring") test.d(7): called from here: foo("somestring") test.d(7): Error: expression foo("somestring") is not a valid template value argument test.d(7): Error: template instance test.bar!(foo("somestring")) error instantiating If code like above should stay invalid the compiler diagnostics should be improved. I.e. recursive dependency on foo when analyzing foo in CTFE. See also the discussion on the list http://forum.dlang.org/thread/mailman.148.1348176167.5162.digitalmar...@puremagic.com http://forum.dlang.org/thread/20120920212236.gd3...@minet.uni-jena.de -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------