curious effect with generics
forsyth opened this issue · 1 comments
Given
procedure Gen3 is
generic
X: Integer;
package Foo_G is
subtype T is Integer range 1 .. X; --- <-(A)
end Foo_G;
package Foo_10 is new Foo_G(X => 10);
package Foo_20 is new Foo_G(X => 20);
begin
null;
end Gen3;
when traversing the generic declaration Foo_G -- not the Foo_10/Foo_20 instantiations but the original generic decl -- if (in the Ada interface) I call P_Is_Static_Expr on the node for the Identifier X in the range specification at (A), it returns True, and P_Eval_As_Int returns 20. If I comment out the declaration of Foo_20, the node X remains static and P_Eval_As_Int returns 10. If I comment out both Foo_x declarations, node X is not static. Is a binding created during the instantiations being left behind in the original generic declaration?
I should add that I first noticed it in connection with instantiations of a subprogram with a formal type parameter, where again it latched on to the type provided by the last appearing instantiation, but this example seemed even simpler.
My impression is that recent changes to libadalang have addressed this notably change 11.50, so I'll close it for you for the time being.