[Issue 20511] New: Can't format JSONValue to OutputRange due to @safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 16 14:00:51 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20511
Issue ID: 20511
Summary: Can't format JSONValue to OutputRange due to @safe
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: minor
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
Consider the following code:
---
import std.format : formattedWrite;
import std.json : JSONValue;
import std.range : nullSink, OutputRange, outputRangeObject;
void main()
{
outputRangeObject!(const(char)[])(nullSink)
.formattedWrite!"%s"(JSONValue.init);
}
---
This should compile, but it instead produces an error. This is caused by
std.json.toJson being `@safe`.
toJson can not be @safe, because it calls arbitrary output range code.
--
More information about the Digitalmars-d-bugs
mailing list