May 28, 2020 [Issue 20874] New: std.json.assign requires '@safe' | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20874 Issue ID: 20874 Summary: std.json.assign requires '@safe' Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: safe Severity: normal Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: pro.mathias.lang@gmail.com ``` import std.json; struct MyCustomType { public string toString () const @system { return null; } alias toString this; } void main () @system { JSONValue json; MyCustomType ilovedlang; json = ilovedlang; } ``` Results in: ``` /usr/local/opt/dmd/include/dlang/dmd/std/json.d(459): Error: @safe function std.json.JSONValue.assign!(MyCustomType).assign cannot call @system function foo.MyCustomType.toString foo.d(5): foo.MyCustomType.toString is declared here /usr/local/opt/dmd/include/dlang/dmd/std/json.d(593): Error: template instance std.json.JSONValue.assign!(MyCustomType) error instantiating foo.d(13): instantiated from here: opAssign!(MyCustomType) ``` Since `assign` is a template, why is it annotated ? >From the discussion in: https://forum.dlang.org/post/tgpqkdghinutpumkouvo@forum.dlang.org -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply