Bug 3437 – No way to make conversions to string in pure functions.

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-10-22T17:30:00Z
Last change time
2015-06-09T01:26:56Z
Assigned to
nobody
Creator
alvcastro

Comments

Comment #0 by alvcastro — 2009-10-22T17:30:11Z
This code can't compile: {{{ import std.conv; pure string genCode(int num) { string result = "auto a = " ~ to!(string)(num) ~ ";"; return result; } void main() { mixin( genCode(1) ); } }}} If you want to generate the body of a pure function with any numerical parameter from outside, there is no way to do it. toStringNow! doesn't help here either. Purity should be checked after the CTFE functions have been executed.
Comment #1 by clugdbug — 2010-02-26T08:14:56Z
This is a Phobos issue. It's just because the to!() functions are not marked as pure. Also the CTFE support for to!() functions is still limited.
Comment #2 by yebblies — 2011-06-12T23:22:58Z
*** This issue has been marked as a duplicate of issue 4850 ***