Ada-Rapporteur-Group / User-Community-Input

Ada User Community Input Working Group - Github Mirror Prototype
26 stars 1 forks source link

Multidimensional array aggregates with outer iterator loop parameter used in subaggregate #64

Open sttaft opened 10 months ago

sttaft commented 10 months ago

Currently the following multidimensional array aggregate is not explicitly illegal, as far as I can tell:

   type Arr is array (Positive range <>, Positive range <>) of Integer;
   X : Arr := [for I in 1 .. 0 => [for J in I .. I + 1 => 42]];

However, this seems to interfere with RM 4.3.3(22):

Any discrete_choices of this aggregate and of its subaggregates are evaluated in an arbitrary order, and converted to the corresponding index type;

which seems to require that we evaluate all of the discrete_choices even for a null array, and in an arbitrary order, which is not possible given the dependence of the range of J on the value of the index parameter I.

It would seem we need to disallow the use of an outer dimension index parameter in a discrete_choice or iterator_specification of a nested subaggregate. We might modify 4.3.3(17) as follows:

The discrete_choice_list of an array_component_association (including an iterated_component_association) is allowed to have a discrete_choice that is a nonstatic choice_expression or that is a subtype_indication or range that defines a nonstatic or null range, only if it is the single discrete_choice of its discrete_choice_list, and either there is only one array_component_association in the enclosing array_component_association_list or the enclosing aggregate is an array_delta_aggregate[Redundant:, not an array_aggregate]._{ In a multidimensional array aggregate, a name denoting an index parameter of an iterated_component_association of an array aggregate shall not occur within a discrete_choice_list or iteratorspecification of a subaggregate of the aggregate.}