Skip to content

Commit 8b74b7e

Browse files
authored
Merge pull request #4229 from ntrel/scope-dip
[spec] Add notes for `scope` attribute/parameter about `-preview=dip1000`
2 parents 9f63844 + 1406d18 commit 8b74b7e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

spec/attribute.dd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,9 @@ $(P
856856
$(LI Assigning a `scope` variable to a non-scope parameter by calling a function)
857857
$(LI Putting a `scope` variable in an array literal)
858858
)
859+
860+
$(NOTE escape analysis is only done in `@safe` code. The $(D -preview=dip1000) switch
861+
must also be enabled.)
859862
$(P
860863
The `scope` attribute is part of the variable declaration, not the type, and it only applies to the first level of indirection.
861864
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
953956
int x;
954957

955958
// this method may be called on a stack-allocated instance of S
956-
void f()
959+
void f() @safe
957960
{
958961
int* p = &x; // inferred `scope int* p`
959962
int* q = &this.x; // equivalent

spec/function.dd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,8 @@ $(H3 $(LNAME2 scope-parameters, Scope Parameters))
19271927
`scope` escape analysis is only done for `@safe` functions. For other functions `scope`
19281928
semantics must be manually enforced.)
19291929

1930+
$(NOTE `@safe` escape analysis is only done with the $(D -preview=dip1000) switch.)
1931+
19301932
---
19311933
@safe:
19321934

0 commit comments

Comments
 (0)