From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: error: choice must be static? Date: Sun, 11 Feb 2024 21:56:17 +0100 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 11 Feb 2024 20:56:17 -0000 (UTC) Injection-Info: dont-email.me; posting-host="4fd62ceeba554ba2f7871a4c75001588"; logging-data="1139391"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UvJu8I70I0CvaX+FqzdMqZOJwBaH9u9E=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:pwwewrBlPA/E3BAkXennqxLGXyk= In-Reply-To: Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:66051 List-Id: On 2024-02-11 13:29, Blady wrote: > Hello, > > I've got the following GNAT error: > > $ gcc -c -gnat2022 -gnatl 2024/test_20240211_static_choice.adb > GNAT 13.2.0 >      1. procedure test_20240211_static_choice is >      2. >      3.    package Maps is >      4.       type Map_Type is private >      5.         with Aggregate =>  (Empty     => Empty_Map, >      6.                             Add_Named => Add_To_Map); >      7.       procedure Add_To_Map (M : in out Map_Type; Key : in Integer; > Value : in String); >      8.       Empty_Map : constant Map_Type; >      9.    private >     10.       type Map_Type is array (1..10) of String (1..10); >     11.       procedure Add_To_Map (M : in out Map_Type; Key : in Integer; > Value : in String) is null; >     12.       Empty_Map : constant Map_Type := [1..10 => "          "]; -- > error: choice must be static >                                                  | >         >>> error: choice must be static > >     13.    end; >     14. >     15. begin >     16.    null; >     17. end; > > I wonder what more static it should be. I don't know what this means, but it's definitely related to the Aggregate aspect. This compiles: procedure Test_20240211_Static_Choice is package Maps is type Map_Type is private with Aggregate => (Empty => Empty_Map, Add_Named => Add_To_Map); procedure Add_To_Map (M : in out Map_Type; Key : in Integer; Value : in String); Empty_Map : constant Map_Type; private type Map_Base is array (1 .. 10) of String (1 .. 10); type Map_Type is new Map_Base; procedure Add_To_Map (M : in out Map_Type; Key : in Integer; Value : in String) is null; Empty_Base : constant Map_Base := (1 .. 10 => (1 .. 10 => ' ') ); Empty_Map : constant Map_Type := Map_Type (Empty_Base); end Maps; begin null; end Test_20240211_Static_Choice; -- Jeff Carter "Nobody expects the Spanish Inquisition!" Monty Python's Flying Circus 22