* Unexpected behavior with partial parameterization of formal packages
@ 2017-07-10 21:47 Roland Laznik
2017-07-11 15:45 ` AdaMagica
0 siblings, 1 reply; 2+ messages in thread
From: Roland Laznik @ 2017-07-10 21:47 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-11 15:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 21:47 Unexpected behavior with partial parameterization of formal packages Roland Laznik
2017-07-11 15:45 ` AdaMagica
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox