From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:620a:444a:: with SMTP id w10mr17857799qkp.294.1614160794051; Wed, 24 Feb 2021 01:59:54 -0800 (PST) X-Received: by 2002:a25:268c:: with SMTP id m134mr49653715ybm.253.1614160793845; Wed, 24 Feb 2021 01:59:53 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 24 Feb 2021 01:59:53 -0800 (PST) In-Reply-To: <6716a4e5-02ac-4735-83c9-28bff3f8aae6n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=94.31.102.170; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 94.31.102.170 References: <4086f350-c56b-4eec-91d3-ef685230b011n@googlegroups.com> <67ea71d9-489a-4802-9cf0-d955f6ecce62n@googlegroups.com> <0e88c615-6a53-4392-b83d-581c59473c88n@googlegroups.com> <6716a4e5-02ac-4735-83c9-28bff3f8aae6n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7a436624-3863-4a0f-a1c5-cf50db419c9cn@googlegroups.com> Subject: Re: "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone" From: AdaMagica Injection-Date: Wed, 24 Feb 2021 09:59:54 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61431 List-Id: 0012...@gmail.com schrieb am Dienstag, 23. Februar 2021 um 23:06:19 UTC+1: > Please help figure out this: > > type CARDS is new cards_numbers range 1..52; > --> > 41:10 missing case values: -128 .. 0 > 41:10 missing case values: 5 .. 127 > 41:25 subtype of expression is not static, alternatives must cover base type > from --> > [card in CARDS, of course] > case (card / 13) +1 is > when 1 => put("Spades"); > when 2 =>put("Hearts"); > when 3 =>put("Spades"); > when 4 =>put("Clovers"); > end case; > > how can the compiler not know that CARD is limited from 1 to 52, including 0 for the base type (type Cards_numbers is range 0..52) Because Card/13 + 1 is a value in CARDS, and there is a rule that all values of the type must be covered. Define a subtype covering only 1..4 and subtype convert the expression, then it shoud be fine.