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=1.5 required=3.0 tests=BAYES_50,FREEMAIL_FROM, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:6214:76f:: with SMTP id f15mr3881799qvz.56.1614117978681; Tue, 23 Feb 2021 14:06:18 -0800 (PST) X-Received: by 2002:a25:5f02:: with SMTP id t2mr43671024ybb.161.1614117978411; Tue, 23 Feb 2021 14:06:18 -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: Tue, 23 Feb 2021 14:06:18 -0800 (PST) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=82.154.190.66; posting-account=rhqvKAoAAABpikMmPHJSZh4400BboHwT NNTP-Posting-Host: 82.154.190.66 References: <4086f350-c56b-4eec-91d3-ef685230b011n@googlegroups.com> <67ea71d9-489a-4802-9cf0-d955f6ecce62n@googlegroups.com> <0e88c615-6a53-4392-b83d-581c59473c88n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6716a4e5-02ac-4735-83c9-28bff3f8aae6n@googlegroups.com> Subject: Re: "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone" From: Mehdi Saada <00120260a@gmail.com> Injection-Date: Tue, 23 Feb 2021 22:06:18 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61428 List-Id: 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) also what's wrong here: Context => type Sets_of_Card is array (Nombre_cartes range <>) of Cards; type CARDS_SETS (Nb: Nombre_cartes := 0) is record Set: Sets_of_Card (1..Nb) := INITIALIZATION (Nb); end record; pack.nb = 5 pack.set'last = 5 faulty line: PACK := (pack.nb-1, Pack.Set(pack.set'First..Pack.Nb-1)); issue: raised CONSTRAINT_ERROR : discriminant check failed and why is this expression not rejected: Pack := (pack.nb+1, pack.set & Card); while this one is rejected ? Pack := (pack.nb+1, pack.set & CARDS_SET'(1=> Card)); a95cop1.adb:126:39: invalid operand types for operator "&" this works but overkill... -> Pack := (pack.nb+1, (pack.set with delta PACK.NB+1 => Card));