Skip to content

Commit

Permalink
Add scope array literals to spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorpel committed Oct 19, 2022
1 parent 2923398 commit 22d1e77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions spec/attribute.dd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/garbage.dd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 22d1e77

Please sign in to comment.