On 8/29/21 8:51 PM, Simon Wright wrote:
>
> the compiler says
>
> value for discriminant "Node_Test" must be static
> non-static function call (RM 4.9(6,18))
This has always been the rule for aggregates.
> OK, I get that (tiresome though it is, and I'm amazed I've never come
> across it before), but how to approach it? I seem to be OK with
That is surprising.
> case Get_Node_Type_Test (T.Node_Type_Part.all) is
> when Text_Node_Test =>
> Location_Step.Node_Test :=
> (Node_Test => Text_Node_Test,
> Name => Null_Unbounded_String);
> when ...
> end case;
>
> but this seems very ugly.
Agreed. What I usually do is
declare
Result : Whatever (D => Non_Static_Value);
-- Discriminant of an object need not be static
begin
Result.F1 := ...;
...
Location_Step.Node_Test := Result;
end;
--
Jeff Carter
"You can never forget too much about C++."
115