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
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)
I wonder why the float list aggregate isn't inferred by the compiler and need some help with a qualification.
On 2023-09-14 22:00, Blady wrote:
I wonder why the float list aggregate isn't inferred by the compiler
and need some help with a qualification.
I'm not sure. But can't you simply write
ML2 : My_Float_List2 := [-3.1, -6.7, 3.3, -3.14, 0.0];
? I presume that My_Float_List2 inherits its aggregate definition from My_Float_List1.
I wonder why the float list aggregate isn't inferred by the compiler and
need some help with a qualification.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 44:35:24 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,858,054 |