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=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,a1265d36600e47dd X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.73.226 with SMTP id o2mr10332978pav.12.1351613454437; Tue, 30 Oct 2012 09:10:54 -0700 (PDT) Received: by 10.68.243.137 with SMTP id wy9mr1445074pbc.0.1351613454406; Tue, 30 Oct 2012 09:10:54 -0700 (PDT) Path: s9ni69865pbb.0!nntp.google.com!kr7no26107111pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 30 Oct 2012 09:10:54 -0700 (PDT) In-Reply-To: <6cc8e815-96c3-4a79-8bcd-e3aea906b889@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <6cc8e815-96c3-4a79-8bcd-e3aea906b889@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <36d9f85f-6daa-4b0b-84b9-1a28d24da2b0@googlegroups.com> Subject: Re: Static bounds of loop - compilation error From: Adam Beneschan Injection-Date: Tue, 30 Oct 2012 16:10:54 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-10-30T09:10:54-07:00 List-Id: On Tuesday, October 30, 2012 6:26:09 AM UTC-7, pascal....@gmail.com wrote: > Hi Ada experts, >=20 > can anyone explain the following compilation errors: >=20 > procedure T is > type E is (A, B, C); > subtype S is E range A .. B; > X, Y : S; > begin > X :=3D A; > Y :=3D B; > for I in S range X .. Y loop > case I is > when A =3D> null; > when B =3D> null; > end case; > end loop; > end T; >=20 > >> missing case value: "C" >=20 > A similar example where S is a subtype of Positive leads to the same err= or and also: bounds of "I" are not static, alternatives must cover base typ= e >=20 > Indeed, X and Y are not static but the bounds of S are, and all the value= s of S are covered in the "case". >=20 > So is it a bug? No. RM 5.4 gives three rules for how the values of a CASE must be covered,= based on the "nominal subtype" of the expression (in this case, the name I= ). If the subtype is static and constrained, then everything in the subtyp= e has to be covered; otherwise, everything in the *base range* has to be co= vered. (The third rule has to do with universal integers and doesn't apply= here.) Here, I's subtype is not static, so therefore that rule doesn't ap= ply, and the only rule left is the rule that everything in the base range h= as to be covered--which means everything in E. There aren't any rules to h= andle a case like you've coded, where I's subtype is non-static but there's= another subtype involved (because if the "S" in "S range X .. Y"); I think= that adding language rules for this would mean that I has yet another kind= of subtype associated with it, in addition to the "actual" and "nominal" s= ubtypes, which would probably make things too complicated. Saying either case S(I) is or case S'(I) is should make things work, because now the CASE expression has a nominal subt= ype S, which is static, rather than "S range X .. Y", which isn't. -- Adam