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.43.71.81 with SMTP id yj17mr17683581icb.26.1410190312274; Mon, 08 Sep 2014 08:31:52 -0700 (PDT) X-Received: by 10.50.114.170 with SMTP id jh10mr270060igb.6.1410190312194; Mon, 08 Sep 2014 08:31:52 -0700 (PDT) Path: border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!uq10no11037134igb.0!news-out.google.com!ht4ni0igb.0!nntp.google.com!r2no16884209igi.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 8 Sep 2014 08:31:51 -0700 (PDT) In-Reply-To: <854mwi1om4.fsf@stephe-leake.org> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <136dc796-8f60-4fc0-a2f8-70e0ca24c9f1@googlegroups.com> <854mwi1om4.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <62e7cd35-9df9-4d26-ae16-62a8725d1184@googlegroups.com> Subject: Re: bug or feature From: Adam Beneschan Injection-Date: Mon, 08 Sep 2014 15:31:52 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:188915 Date: 2014-09-08T08:31:51-07:00 List-Id: On Monday, September 8, 2014 1:52:01 AM UTC-7, Stephen Leake wrote: >=20 > > 1 with Ada.Text_IO; > > 2 with Datum_Pkg; > > 3 =20 > > 4 procedure Main is > > 5=20 > > 6 subtype Datum is Datum_Pkg.Datum; > > 7 subtype Datum_Vector is Datum_Pkg.Datum_Vectors.Vector; > > 8 =20 > > 9 D_Vec : Datum_Vector; > > 10 =20 > > 11 begin > > 12 =20 > > 13 for Dat : Datum_Pkg.Datum of D_Vec loop > > 14 Ada.Text_IO.Put_Line ("Datum=3D" & Dat.Image); > > 15 end loop; > > 16 =20 > > 17 for Dat : Datum of D_Vec loop > > 18 Ada.Text_IO.Put_Line ("Datum=3D" & Dat.Image); > > 19 end loop; =20 > > 20 =20 > > 21 end Main; >=20 > > 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 de= finition > > in line 6. >=20 > line 6 defines a _new_ subtype, _different_ from Datum_Pkg.Datum. They ha= ve > the same base type, but the error message says "subtype", not "base > type". >=20 > So you are out of luck. >=20 > 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. But that doesn't explain why he's getting a *compile-time* error. As far as I can tell from the RM, you'd get an exception at run-time only i= f the subtype_indication is more restrictive than the container element *an= d* if the code actually tries to assign the loop parameter to an element th= at does not satisfy the subtype constraints. This one looks like a GNAT bu= g to me. -- Adam