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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: bug or feature References: <136dc796-8f60-4fc0-a2f8-70e0ca24c9f1@googlegroups.com> Date: Mon, 08 Sep 2014 03:51:47 -0500 Message-ID: <854mwi1om4.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (windows-nt) Cancel-Lock: sha1:M2usbKZkXycAEHGQoSuKVo9Na50= MIME-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: b3a1a540d6e2fe3fb833014162 X-Received-Bytes: 2056 X-Received-Body-CRC: 4174680234 Xref: number.nntp.dca.giganews.com comp.lang.ada:188912 Date: 2014-09-08T03:51:47-05:00 List-Id: Charly writes: > 1 with Ada.Text_IO; > 2 with Datum_Pkg; > 3 > 4 procedure Main is > 5 > 6 subtype Datum is Datum_Pkg.Datum; > 7 subtype Datum_Vector is Datum_Pkg.Datum_Vectors.Vector; > 8 > 9 D_Vec : Datum_Vector; > 10 > 11 begin > 12 > 13 for Dat : Datum_Pkg.Datum of D_Vec loop > 14 Ada.Text_IO.Put_Line ("Datum=" & Dat.Image); > 15 end loop; > 16 > 17 for Dat : Datum of D_Vec loop > 18 Ada.Text_IO.Put_Line ("Datum=" & Dat.Image); > 19 end loop; > 20 > 21 end Main; > > Line 13 compiles without message but in line 17 I get an error message: > subtype indication does not match element type > But this line should be equivalent to line 13 because of the subtype definition > in line 6. line 6 defines a _new_ subtype, _different_ from Datum_Pkg.Datum. They have the same base type, but the error message says "subtype", not "base type". So you are out of luck. In general, a subtype can add constraints, which is why this matters; if the loop parameter has different constraints than the container object, you'll get runtime errors. It might be possible to allow a "no new constraints" subtype such as yours to be considered to match, but I suspect there are problems with that as well. -- -- Stephe