I try to compile an Ada 95 program with an Ada 2012 compiler. However there are problems with instantiation of the generic package Garbage_Collector. The subtype A_Term is not accepted in the package instantiation:
prolog.adb:27:15: designated type of actual does not match that of formal "Link"
prolog.adb:27:15: instantiation abandoned
I have tried to change A_Term to type A_Term is access A_Node;. Then the package will instantiate, but the rest of the code breaks. Has something changed since Ada 95 and how can I make it work in Ada 2012?
procedure Prolog is
generic
type Item is limited private;
type Link is access Item;
package Garbage_Collector is
procedure Get (L : in out Link) is null;
end Garbage_Collector;
type Node_Tag is (A, B);
type Node (Tag : Node_Tag);
type Term is access Node;
type Node (Tag : Node_Tag) is
record
case Tag is
when A => null;
when B => null;
end case;
end record;
subtype A_Node is Node (A);
subtype A_Term is Term (A);
package Gc_A is new Garbage_Collector
(Item => A_Node,
Link => A_Term);
T : Term;
begin
Gc_A.Get (T);
end Prolog;
The code is from a Prolog module from Stanford University. The project on GitHub