From 22d1e773c8592bcefb1599cdb9284e3d0670e737 Mon Sep 17 00:00:00 2001 From: Dennis Korpel Date: Wed, 19 Oct 2022 12:14:27 +0200 Subject: [PATCH] Add scope array literals to spec --- spec/attribute.dd | 18 ++++++++++++++++++ spec/garbage.dd | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/attribute.dd b/spec/attribute.dd index aa887291f3..2075ec65ec 100644 --- a/spec/attribute.dd +++ b/spec/attribute.dd @@ -843,6 +843,24 @@ void main() @nogc } --- +$(H3 $(LNAME2 scope-array-literal, Initializing a $(D scope) variable with an array literal)) +$(P + When a `scope` dynamic array variable or parameter is initialized with an array literal, + the array may be allocated on the stack and permitted in a `@nogc` context. +) + +$(SPEC_RUNNABLE_EXAMPLE_COMPILE +--------------- +void fun(scope int[] x); + +void main() @nogc +{ + fun([10, 20, 30]); + scope int[] x = [40, 50, 60]; +} +--------------- +) + $(H2 $(LNAME2 abstract, $(D abstract) Attribute)) $(P diff --git a/spec/garbage.dd b/spec/garbage.dd index 5f7f4c9f4f..9321700658 100644 --- a/spec/garbage.dd +++ b/spec/garbage.dd @@ -372,7 +372,7 @@ $(H2 D $(LNAME2 op_involving_gc, Operations That Involve the Garbage Collector)) $(LI $(GLINK2 expression, NewExpression)) $(LI Array appending) $(LI Array concatenation) - $(LI Array literals (except when used to initialize static data)) + $(LI Array literals (except when used to initialize static data or $(DDSUBLINK spec/attribute, scope, `scope`) variables)) $(LI Associative array literals) $(LI Any insertion, removal, or lookups in an associative array) $(LI Extracting keys or values from an associative array)