https://issues.dlang.org/show_bug.cgi?id=19873
Walter Bright <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #5 from Walter Bright <[email protected]> --- Here's what's happening: ------- reduced test case ---------- void test() { int i; int* p = &i; // <= `scope` is inferred for `p` int*[] slicep = [p]; } ---------------------- If it is declared: scope int*p = &i; the error will occur regardless of the application of @system. Looking at the code in escape.d checkAssignEscape(): ------------ // Try to infer 'scope' for va if in a function not marked @system bool inferScope = false; if (va && sc.func && sc.func.type && sc.func.type.ty == Tfunction) inferScope = (cast(TypeFunction)sc.func.type).trust != TRUST.system; ------------ https://github.com/dlang/dmd/blob/master/src/dmd/escape.d#L578 and there it is. It is deliberate. What's going on is there are actually 4 trust levels - system, trusted, safe, and default_. The fourth state default_ is necessary for functions that will have their attributes inferred. I went a little further here to assume a bit more @safety in default_ functions unless the user specifically marked it as @system. As you know, I'd like to see @safe as the default. While this issue is a bug, it's in the direction we need to go anyway so it shouldn't be "fixed". --
