From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.99.111.8 with SMTP id k8mr7753261pgc.148.1499723269561; Mon, 10 Jul 2017 14:47:49 -0700 (PDT) X-Received: by 10.36.9.82 with SMTP id 79mr545648itm.2.1499723269522; Mon, 10 Jul 2017 14:47:49 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!v202no2090962itb.0!news-out.google.com!s132ni3080itb.0!nntp.google.com!188no2094480itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 10 Jul 2017 14:47:49 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.235.206.67; posting-account=coJr2goAAABHBj_5Cw6Kgm_h7B1DBIyH NNTP-Posting-Host: 93.235.206.67 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <21ff0d1f-c5f3-4c23-b974-80fed8ebdf55@googlegroups.com> Subject: Unexpected behavior with partial parameterization of formal packages From: Roland Laznik Injection-Date: Mon, 10 Jul 2017 21:47:49 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:47351 Date: 2017-07-10T14:47:49-07:00 List-Id: I stumbled on an issue with partial parameterization of formal packages. In my opinion, the following Ada 2012 code is legal: ======================== main.adb pprocedure Main is -- Line 1 generic package As is end As; generic type T is private; with package A0 is new As; -- Line 9 package Bs is end Bs; generic with package Xa is new As; package Xs is package Xb is new Bs(T => Integer, A0 => Xa); -- Line 16 end Xs; generic with package Yb is new Bs(T => Integer, others => <>); -- Line 20 package Ys is end Ys; package A is new As; package X is new Xs(Xa => A); -- Line 25 package Y is new Ys(Yb => X.Xb); -- Line 26 begin null; end Main; ======================== However, gnat reports an error: ======================== $ gnatmake main.adb gcc -c main.adb main.adb:26:31: actual for "A0" in actual instance does not match formal gnatmake: "main.adb" compilation error ======================== I expect A0 eventually being set to A because - X is new Xs(Xa => A) [Line 25], therefore - X.Xb is new Bs(T => Integer, A0 => Xa) [line 16], with Xa = A, therefore A0 = A If the partial parametrization in line 20 is removed, the code compiles. But this should not change the setting for A0 and the same error should be reported. ======================== with package Yb is new Bs(others => <>); -- Modified Line 20 ======================== gnat/gnatmake are from the 2017 version of GNAT GPL: ======================== $ gnatmake --version GNATMAKE GPL 2017 (20170515-63) Copyright (C) 1995-2017, Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gcc --version gcc (GCC) 6.3.1 20170510 (for GNAT GPL 2017 20170515) Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. See your AdaCore support agreement for details of warranty and support. If you do not have a current support agreement, then there is absolutely no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ======================== Did I get the semantics of partial parametrization wrong or is there a bug in gnat? Thanks in advance, Roland