From ff26160e4b804cf5c9a26cca2fe4a956de91f41d Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 3 May 2025 12:38:02 +0100 Subject: [PATCH] [spec/expression] Improve AssignExpression docs for arrays Differentiate between an a slice expression and assigning to an array. Rename 'Array Setting' to 'Array Filling' and tweak wording. --- spec/arrays.dd | 6 +++--- spec/expression.dd | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/arrays.dd b/spec/arrays.dd index 5d7a808241..2ca4144411 100644 --- a/spec/arrays.dd +++ b/spec/arrays.dd @@ -418,12 +418,12 @@ assert(s == [2, 3, 3, 4]); ) -$(H2 $(LNAME2 array-setting, Array Setting)) +$(H2 $(LNAME2 array-setting, Array Filling)) $(P If a slice operator appears as the left-hand side of an assignment expression, and the type of the right-hand side is the same as the - element type of the left-hand side, then the array contents of the - left-hand side are set to the right-hand side. + element type of the left-hand side, then each element of the slice + expression will be assigned to the value on the right-hand side. ) $(SPEC_RUNNABLE_EXAMPLE_RUN diff --git a/spec/expression.dd b/spec/expression.dd index 45e0379816..71569c51e5 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -384,9 +384,13 @@ $(H3 $(LNAME2 simple_assignment_expressions, Simple Assignment Expression)) as described in $(DDSUBLINK spec/arrays, resize, Setting Dynamic Array Length). ) - $(LI If the lvalue is a static array or a slice, the behavior is as + $(LI If the left operand is a slice expression, the behavior is as described in $(DDSUBLINK spec/arrays, array-copying, Array Copying) and - $(DDSUBLINK spec/arrays, array-setting, Array Setting). + $(DDSUBLINK spec/arrays, array-setting, Array Filling). + ) + + $(LI If the lvalue is an array, the behavior is as described in + $(DDSUBLINK spec/arrays, assignment, Array Assignment). ) $(LI If the lvalue is a user-defined property, the behavior is as