You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In dmd 2.066alpha this compiles and runs:
void main() pure nothrow {
import std.conv: text;
int x = 10;
assert(text(x) == "10");
}
While thios:
void main() pure nothrow {
import std.bigint: BigInt;
import std.conv: text;
BigInt x = 10;
assert(text(x) == "10");
}
temp.d(5,16): Error: pure function 'D main' cannot call impure function 'std.conv.text!(BigInt).text'
temp.d(5,16): Error: 'std.conv.text!(BigInt).text' is not nothrow
temp.d(1,6): Error: function 'D main' is nothrow yet may throw
The text was updated successfully, but these errors were encountered:
Fixing #6007 may involve a solution which isn't strictly pure (global cache of powers of the base we're converting to.)
This is the solution OpenJDK's biginteger class uses, whether or not we use a global cache or recompute the powers each time is a design issue for the person who decides to fix #6007.
Anyways, I think we should not be so eager in adding pure to the conversion to string unless we have a "trusted pure" available.
bearophile_hugs reported this on 2014-05-28T22:45:49Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=12817
CC List
Description
In dmd 2.066alpha this compiles and runs: void main() pure nothrow { import std.conv: text; int x = 10; assert(text(x) == "10"); } While thios: void main() pure nothrow { import std.bigint: BigInt; import std.conv: text; BigInt x = 10; assert(text(x) == "10"); } temp.d(5,16): Error: pure function 'D main' cannot call impure function 'std.conv.text!(BigInt).text' temp.d(5,16): Error: 'std.conv.text!(BigInt).text' is not nothrow temp.d(1,6): Error: function 'D main' is nothrow yet may throwThe text was updated successfully, but these errors were encountered: