From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Limited returns
Date: Mon, 23 Jun 2008 16:21:07 +0200
Date: 2008-06-23T16:21:07+02:00 [thread overview]
Message-ID: <pt291p6yh4g9.1iey97ygy74vl.dlg@40tude.net> (raw)
Let's consider this:
with Ada.Finalization;
procedure Test_Limited_Stuff is
type I is limited interface;
type T is new Ada.Finalization.Limited_Controlled with record
A : Integer;
end record;
type S is new T and I with record
Self : not null access S'Class := S'Unchecked_Access;
end record;
function Factory return I'Class is
begin
return X : S;
-- GNAT: wrong type for return_subtype_indication
end Factory;
begin
null;
end Test_Limited_Stuff;
Is it illegal? I am surprised why? S is in I'Class.
OK, if that is indeed illegal, then let's make another try:
function Factory return I'Class is
begin
return X : I'Class := S'(T with others => <>);
-- GNAT: expected an access type with designated type "S'Class" defined ...
-- found an access type with designated type "I'Class" defined ...
end Factory;
...still illegal, but more interesting. It seems that a Rosen's trick
member cannot be initialized because the object's type is more general than
the designated access type. It should not be so. A compiler bug?
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next reply other threads:[~2008-06-23 14:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-23 14:21 Dmitry A. Kazakov [this message]
2008-06-23 15:04 ` Limited returns fedya_fedyakoff
2008-06-23 15:20 ` fedya_fedyakoff
2008-06-23 16:53 ` Dmitry A. Kazakov
2008-06-24 10:56 ` fedya_fedyakoff
2008-06-24 13:51 ` Dmitry A. Kazakov
2008-06-24 15:01 ` fedya_fedyakoff
2008-06-24 16:31 ` Dmitry A. Kazakov
2008-06-24 16:42 ` Dmitry A. Kazakov
2008-06-23 15:49 ` Adam Beneschan
2008-06-24 10:13 ` fedya_fedyakoff
2008-06-23 15:15 ` Adam Beneschan
2008-06-23 17:03 ` Dmitry A. Kazakov
2008-06-23 18:15 ` Adam Beneschan
2008-06-23 19:44 ` Dmitry A. Kazakov
2008-06-26 12:35 ` Egil Høvik
2008-06-26 14:12 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox