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

Purity issue on merge-2.064 branch #575

Closed
Hackerpilot opened this issue Jan 20, 2014 · 3 comments
Closed

Purity issue on merge-2.064 branch #575

Hackerpilot opened this issue Jan 20, 2014 · 3 comments

Comments

@Hackerpilot
Copy link

I'm getting the following error when using an LDC compiled from 4006fbb:

/usr/local/include/d/std/array.d(2222): Error: pure function 'std.array.Appender!string.Appender.ensureAddable' cannot call impure function 'core.stdc.string.memcpy'
/usr/local/include/d/std/range.d(614): Error: static assert  "Cannot put a string into a Appender!string"
/usr/local/include/d/std/format.d(2185):        instantiated from here: put!(Appender!string, string)
/usr/local/include/d/std/format.d(1907):        instantiated from here: formatRange!(Appender!string, string[], char)
/usr/local/include/d/std/conv.d(107):        instantiated from here: formatValue!(Appender!string, string[], char)
/usr/local/include/d/std/conv.d(866):        ... (4 instantiations, -v to show) ...
/usr/local/include/d/std/algorithm.d(8411):        instantiated from here: text!(string, string, string, string[], string)
stdx/lexer.d(327):        instantiated from here: sort!("a < b", cast(SwapStrategy)0, string[])

This same call to sort() during CTFE works with DMD.

@redstar
Copy link
Member

redstar commented Jan 20, 2014

Thanks for the report. What are you trying to compile (or better, do you have a small test case)?

@Hackerpilot
Copy link
Author

import std.algorithm;
import std.stdio;

string f(string[] args)
{
    return `"whatever"`;
}

string[] arr(R)(R r)
{
    string[] s;
    foreach (i; r)
        s ~= i;
    return s;
}

enum items = ["abc", "def"];
enum a = f(arr(sort(items)));

void main(string[] args)
{
    mixin ("auto b = [" ~ a ~ "];");
    writeln(b);
}

@dnadlinger
Copy link
Member

Seems like this issues has been fixed in Git master (2.065-based). You example code compiles fine for me.

redstar pushed a commit that referenced this issue Sep 27, 2014
add implementation notes to dmain2.d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants