comp.lang.ada
 help / color / mirror / Atom feed
* Limited returns
@ 2008-06-23 14:21 Dmitry A. Kazakov
  2008-06-23 15:04 ` fedya_fedyakoff
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Dmitry A. Kazakov @ 2008-06-23 14:21 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-06-26 14:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-23 14:21 Limited returns Dmitry A. Kazakov
2008-06-23 15:04 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox