AdaCore / gnatstudio

GNAT Studio is a powerful and lightweight IDE for Ada and SPARK.
399 stars 52 forks source link

iterator specification refused witihout subtype qualification #177

Open evanescente-ondine opened 2 months ago

evanescente-ondine commented 2 months ago

Hi, The iterator specification in the loop statement of the following sample down there

for LINE : String of [for I in Letters'range => S(I) & M(I)] loop

is refused, with error: name expected. But it seems to me there should be enough information to infer the subtype unambiguously. And the "String" is superfluous too, as the expression's type should be obvious too. Is it a version issue (GNAT 13.3.0) or did I misunderstand the standard ?

Thanks.

pragma Ada_2022;
pragma Extensions_Allowed (On);
with Ada.Text_IO; use Ada.Text_IO;

procedure DISPLAY_INITIALS is
   type Letters is array (1..8) of String;
   M : constant Letters :=
     ["*             *",
      "**           **",
      "* *         * *",
      "*  *       *  *",
      "*   *     *   *",
      "*    *   *    *",
      "*     * *     *",
      "*      *      *"];
   S : constant Letters :=
     ["***************",
      "*             *",
      "*             *",
      "*             *",
      "***************",
      "              *",
      "              *",
      "***************"];
begin
      for LINE : String of [for I in Letters'range => S(I) & M(I)] loop
         PUT_LINE(LINE);
      end loop;
end;