Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pure nothrow text(BigInt) too #10058

Open
dlangBugzillaToGithub opened this issue May 28, 2014 · 1 comment
Open

pure nothrow text(BigInt) too #10058

dlangBugzillaToGithub opened this issue May 28, 2014 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2014-05-28T22:45:49Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=12817

CC List

  • safety0ff.bugz

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 throw
@dlangBugzillaToGithub
Copy link
Author

safety0ff.bugz commented on 2014-05-28T22:56:33Z

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.

@thewilsonator thewilsonator added std.bigint and removed OS:Windows Issues Specific to Windows Arch:x86 Issues specific to x86 P4 labels Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants