File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 856
856
$(LI Assigning a `scope` variable to a non-scope parameter by calling a function)
857
857
$(LI Putting a `scope` variable in an array literal)
858
858
)
859
+
860
+ $(NOTE escape analysis is only done in `@safe` code. The $(D -preview=dip1000) switch
861
+ must also be enabled.)
859
862
$(P
860
863
The `scope` attribute is part of the variable declaration, not the type, and it only applies to the first level of indirection.
861
864
For example, it is impossible to declare a variable as a dynamic array of scope pointers, because `scope` only applies to the `.ptr`
@@ -953,7 +956,7 @@ struct S
953
956
int x;
954
957
955
958
// this method may be called on a stack-allocated instance of S
956
- void f()
959
+ void f() @safe
957
960
{
958
961
int* p = &x; // inferred `scope int* p`
959
962
int* q = &this.x; // equivalent
Original file line number Diff line number Diff line change @@ -1927,6 +1927,8 @@ $(H3 $(LNAME2 scope-parameters, Scope Parameters))
1927
1927
`scope` escape analysis is only done for `@safe` functions. For other functions `scope`
1928
1928
semantics must be manually enforced.)
1929
1929
1930
+ $(NOTE `@safe` escape analysis is only done with the $(D -preview=dip1000) switch.)
1931
+
1930
1932
---
1931
1933
@safe:
1932
1934
You can’t perform that action at this time.
0 commit comments