Skip to content

Commit 0623b30

Browse files
committed
Add scope array literals to spec
1 parent 2923398 commit 0623b30

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

spec/attribute.dd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,24 @@ void main() @nogc
843843
}
844844
---
845845

846+
$(H3 $(LNAME2 scope-array-literal, Initializing a $(D scope) variable with an array literal))
847+
$(P
848+
When a `scope` dynamic array variable or parameter is initialized with an array literal,
849+
the array may be allocated on the stack and permitted in a `@nogc` context.
850+
)
851+
852+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
853+
---------------
854+
void fun(scope int[] x) @nogc;
855+
856+
void main() @nogc
857+
{
858+
fun([10, 20, 30]);
859+
scope int[] x = [40, 50, 60];
860+
}
861+
---------------
862+
)
863+
846864
$(H2 $(LNAME2 abstract, $(D abstract) Attribute))
847865

848866
$(P

spec/garbage.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ $(H2 D $(LNAME2 op_involving_gc, Operations That Involve the Garbage Collector))
372372
$(LI $(GLINK2 expression, NewExpression))
373373
$(LI Array appending)
374374
$(LI Array concatenation)
375-
$(LI Array literals (except when used to initialize static data))
375+
$(LI Array literals (except when used to initialize static data or $(DDSUBLINK spec/attribute, scope, `scope`) variables))
376376
$(LI Associative array literals)
377377
$(LI Any insertion, removal, or lookups in an associative array)
378378
$(LI Extracting keys or values from an associative array)

0 commit comments

Comments
 (0)