From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:198a:b0:403:ab15:17a0 with SMTP id u10-20020a05622a198a00b00403ab1517a0mr11211qtc.12.1690410389506; Wed, 26 Jul 2023 15:26:29 -0700 (PDT) X-Received: by 2002:a4a:4fd5:0:b0:563:6b94:ab7f with SMTP id c204-20020a4a4fd5000000b005636b94ab7fmr1154150oob.1.1690410388757; Wed, 26 Jul 2023 15:26:28 -0700 (PDT) Path: eternal-september.org!news.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 26 Jul 2023 15:26:28 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns NNTP-Posting-Host: 98.59.238.112 References: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Rosetta Code task Proper divisors fails to compile From: Kenneth Wolcott Injection-Date: Wed, 26 Jul 2023 22:26:29 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:65456 List-Id: On Wednesday, July 26, 2023 at 12:57:40=E2=80=AFPM UTC-7, Jeffrey R.Carter = wrote: > On 2023-07-26 20:30, Kenneth Wolcott wrote:=20 > >=20 > > Thank you for your suggestion. Doesn't seem to have any effect. > Interesting. I get the same results with GNAT 12.=20 >=20 > Looking more closely at the code, I think the error, while its msg is=20 > misleading, is correct. A function that returns a limited type can only r= eturn=20 > an aggregate, a function call, or an object declared by an extended retur= n=20 > statement. The generic formal object None is none of these.=20 >=20 > Changing the generic parameter to a function=20 >=20 > with function None return Result_Type;=20 >=20 > makes the code correct. You need to change the definition of Empty in=20 > Proper_Divisors=20 >=20 > function Empty return Pos_Arr is (1 .. 0 =3D> <>);=20 >=20 > and create a function to supply for the 2nd instantiation=20 >=20 > function None return Natural is (0);=20 > ...=20 > package Divisor_Count is new Generic_Divisors=20 > (Result_Type =3D> Natural, None =3D> None, One =3D> Cnt, Add =3D> "+");= =20 >=20 > and then it compiles and runs.=20 >=20 > Another possibility is to make Result_Type simply private, though that is= =20 > slightly less general. That may be how the OP got the code to compile and= run.=20 > It might be that limited was added later because the OP saw that it could= be,=20 > and never tested the change. Hi Jeff; Thank you for your reply. I went with the latter suggestion for my local use. Ken