Issue 13300 - pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit'
Summary: pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call i...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: Eduard Staniloiu
URL:
Keywords: pull, rejects-valid
: 18992 (view as issue list)
Depends on: 13333
Blocks:
  Show dependency treegraph
 
Reported: 2014-08-15 20:48 UTC by Vladimir Panteleev
Modified: 2020-03-21 03:56 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2014-08-15 20:48:41 UTC
////////// test.d //////////
import std.array;
import std.variant;

alias Algebraic!bool Value;

struct T
{
    Value value;
    @disable this();
}

void main()
{
    auto a = appender!(T[]);
}
////////////////////////////

Compiler output:

C:\...\std\array.d(2400,34): Error: pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit'
C:\...\std\array.d(2729,1): Error: template instance std.array.Appender!(T[]) error instantiating
test.d(14,11):        instantiated from here: appender!(T[])

Introduced in https://github.com/D-Programming-Language/phobos/pull/2147
Comment 1 Vladimir Panteleev 2014-08-15 20:50:23 UTC
This regression affects the SDLang library:
https://github.com/Abscissa/SDLang-D
Comment 3 github-bugzilla 2014-08-22 19:26:30 UTC
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/1baf12b102cc430229d3072433d877f5dc1b0ffb
fix Issue 13300 - pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit'

https://github.com/D-Programming-Language/phobos/commit/ef1b0bcf97e12bcc6a2a3202c0f9da6660e0c13e
Merge pull request #2439 from 9rnsr/fix13300

[REG2.067a] Issue 13300 - pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit'
Comment 4 Andrea Fontana 2018-06-15 12:59:41 UTC
Same problem, for structs with impure postblit.
I think those functions should be templatized. Or maybe we can remove pure at all and add a unittest to force test against pure structs.

------

import std.experimental.all;

int i;

void main()
{
    Range r;
    r.array().writeln;
}

struct Simple
{
    @disable this(); // Without this, it works.
    this(this) { i++; }
    
    private:
    this(int tmp) { }
}

struct Range
{
    @property Simple front() { return S(0); }
    void popFront() { count++; }
    @property empty() { return count < 3; }
    size_t count;
}
Comment 5 basile-z 2018-08-25 20:58:33 UTC
*** Issue 18992 has been marked as a duplicate of this issue. ***
Comment 6 Eduard Staniloiu 2018-12-18 17:25:37 UTC
PR - https://github.com/dlang/phobos/pull/6811
Comment 7 github-bugzilla 2018-12-24 19:22:02 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/c575e985b3dccce3d807165c5b98c8d1862ec366
Fix Issue 13300 - pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit'

https://github.com/dlang/phobos/commit/c7106f02b911c7ca14e3873f5b76cadfb26c5071
Merge pull request #6811 from edi33416/issue_13300

Fix Issue 13300 - pure function 'std.array.Appender!(T[]).Appender.en…