Polymorphic Copy (from Rosetta Code) fails to compile

Hi;

Hopefully I’m not doing something really stupid here; I really don’t want to waste your time :slight_smile:

Polymorphic Copy (from Rosetta Code) fails to compile

gcc -c -I./ -I- ./test_polymorphic_copy.adb
test_polymorphic_copy.adb:29:04: error: “end Clone;” expected
gnatmake: “./test_polymorphic_copy.adb” compilation error

Well, this sounds obvious:

change:
29 end Copier;
to
29 end Clone;

But then I got all kinds of errors:

gcc -c -I./ -I- ./test_polymorphic_copy.adb
test_polymorphic_copy.adb:28:25: error: invalid constraint: type has no discriminant
test_polymorphic_copy.adb:28:25: error: if qualified expression was meant, use apostrophe
test_polymorphic_copy.adb:46:30: error: invalid use of subtype mark in expression or call
test_polymorphic_copy.adb:47:30: error: invalid use of subtype mark in expression or call
gnatmake: “./test_polymorphic_copy.adb” compilation error

So, maybe not so obvious what went wrong…

Thanks,
Retired_Build_Engineer

line 28: return new T’Class’(X);. As the error message said, if qualified expression was meant, use apostrophe.

line 46: Object_3 : T_ptr := Clone(Object_1);. As the error message said, invalid use of subtype mark in expression or call.
Line 47: likewise.