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.
@FeepingCreature created dlang/phobos pull request #7354 "Fix issue 20511: make toJSON determine safeness based on output range safeness." fixing this issue: - Fix issue 20511: make toJSON infer safeness based on output range safeness. https://github.com/dlang/phobos/pull/7354
dlang/phobos pull request #7354 "Fix issue 20511: make toJSON determine safeness based on output range safeness." was merged into stable: - 3e26069a4f7383e02e12df35f4b92cfa4ac113a4 by Mathis Beer: Fix issue 20511: make toJSON infer safeness based on output range safeness. https://github.com/dlang/phobos/pull/7354