From mboxrd@z Thu Jan 1 00:00:00 1970
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
ip-172-31-65-14.ec2.internal
X-Spam-Level:
X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,FREEMAIL_FROM,
NICE_REPLY_A,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no
version=3.4.6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Blady
Newsgroups: comp.lang.ada
Subject: Re: Aggregate with derived types.
Date: Thu, 14 Sep 2023 22:00:19 +0200
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: Thu, 14 Sep 2023 20:00:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8143c6364d43b82ae9baf354387a001e";
logging-data="2915793"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19f9l+mnFiTcROLdAGHXTAA"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.15.0
Cancel-Lock: sha1:WGVY0gKbjK3XHllz3s+YsMWcz7M=
Content-Language: fr, en-US
In-Reply-To:
Xref: news.eternal-september.org comp.lang.ada:65652
List-Id:
Le 14/09/2023 à 17:31, Jeffrey R.Carter a écrit :
> On 2023-09-14 16:02, Blady wrote:
>>
>> 1. with Ada.Containers.Vectors;
>> 2. with Ada.Text_IO;
>> 3. procedure test_20230914_derived_agg is
>> 4. package My_Float_Lists is new Ada.Containers.Vectors
>> (Positive, Float);
>> 5. subtype My_Float_List1 is My_Float_Lists.Vector;
>> 6. type My_Float_List2 is new My_Float_Lists.Vector with null
>> record;
>> 7. ML1 : My_Float_List1 := [-3.1, -6.7, 3.3, -3.14, 0.0];
>> 8. ML2 : My_Float_List2 := ([-3.1, -6.7, 3.3, -3.14, 0.0]
>> with null record);
>> |
>> >>> error: no unique type for this aggregate
>
> IIUC, you have to qualify the value:
>
> (My_Float_List1'[-3.1, -6.7, 3.3, -3.14, 0.0] with null record)
>
> or
>
> (My_Float_Lists.Vector'[-3.1, -6.7, 3.3, -3.14, 0.0] with null record)
>
> (not tested)
Thanks Jeff, both proposals are compiled ok by GNAT.
I wonder why the float list aggregate isn't inferred by the compiler and
need some help with a qualification.