[Issue 20351] New: Unknown error, should actually be: pure function cannot call impure function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 4 02:21:48 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20351
Issue ID: 20351
Summary: Unknown error, should actually be: pure function
cannot call impure function
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: diagnostic, ice-on-invalid-code
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: elpenguino+D at gmail.com
```
import std.format : formattedWrite;
import std.typecons : Nullable;
struct GS {
BS bs;
static int gTD() {
static Nullable!GS ltd;
return 0;
}
}
struct BS {
void toString(T)(T sink) const {
sink.formattedWrite!"%s"(c());
}
}
static immutable uint d;
struct C(T) {
void toString(F)(F sink) const {
import std.format : formattedWrite;
sink.formattedWrite!"%s"(1.0);
}
void __toString() pure {
import std.array : Appender;
auto buf = new Appender!(char[]);
toString(buf);
}
}
auto c()() {
return C!(double)();
}
```
The real error here is that C!double.__toString() can't call impure function
C!double.toString().
--
More information about the Digitalmars-d-bugs
mailing list