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=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Rosetta Code task Proper divisors fails to compile Date: Wed, 26 Jul 2023 21:57:37 +0200 Organization: A noiseless patient Spider Message-ID: References: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 26 Jul 2023 19:57:37 -0000 (UTC) Injection-Info: dont-email.me; posting-host="983f2e8298054c59f21c59c0da0031b5"; logging-data="1637293"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++LxxNT6PfUt9Tq3XEzoGKnOr1M8L3/fM=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cancel-Lock: sha1:zowlo/F4YMXLYUp+3MGIqJUUbT8= In-Reply-To: Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:65453 List-Id: On 2023-07-26 20:30, Kenneth Wolcott wrote: > > Thank you for your suggestion. Doesn't seem to have any effect. Interesting. I get the same results with GNAT 12. Looking more closely at the code, I think the error, while its msg is misleading, is correct. A function that returns a limited type can only return an aggregate, a function call, or an object declared by an extended return statement. The generic formal object None is none of these. Changing the generic parameter to a function with function None return Result_Type; makes the code correct. You need to change the definition of Empty in Proper_Divisors function Empty return Pos_Arr is (1 .. 0 => <>); and create a function to supply for the 2nd instantiation function None return Natural is (0); ... package Divisor_Count is new Generic_Divisors (Result_Type => Natural, None => None, One => Cnt, Add => "+"); and then it compiles and runs. Another possibility is to make Result_Type simply private, though that is slightly less general. That may be how the OP got the code to compile and run. It might be that limited was added later because the OP saw that it could be, and never tested the change. -- Jeff Carter "I'm a lumberjack and I'm OK." Monty Python's Flying Circus 54