comp.lang.ada
 help / color / mirror / Atom feed
From: Blady <p.p11@orange.fr>
Subject: Re: Aggregate with derived types.
Date: Thu, 14 Sep 2023 22:00:19 +0200	[thread overview]
Message-ID: <udvooj$2oveh$1@dont-email.me> (raw)
In-Reply-To: <udv914$2kqji$1@dont-email.me>

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.

  reply	other threads:[~2023-09-14 20:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 14:02 Aggregate with derived types Blady
2023-09-14 15:31 ` Jeffrey R.Carter
2023-09-14 20:00   ` Blady [this message]
2023-09-14 21:37     ` Jeffrey R.Carter
2023-09-15  7:27       ` Blady
2023-09-16  6:39     ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox