From: Mehdi Saada <00120260a@gmail.com>
Subject: Re: "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone"
Date: Tue, 23 Feb 2021 14:06:18 -0800 (PST) [thread overview]
Message-ID: <6716a4e5-02ac-4735-83c9-28bff3f8aae6n@googlegroups.com> (raw)
In-Reply-To: <e0673262-4429-4486-b379-fd9524e2dae4n@googlegroups.com>
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));
next prev parent reply other threads:[~2021-02-23 22:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 0:14 "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone" Mehdi Saada
2021-02-22 6:32 ` J-P. Rosen
2021-02-22 10:14 ` AdaMagica
2021-02-22 10:57 ` Dmitry A. Kazakov
2021-02-22 14:20 ` Mehdi Saada
2021-02-22 15:11 ` J-P. Rosen
2021-02-22 15:55 ` Dmitry A. Kazakov
2021-02-22 16:21 ` Mehdi Saada
2021-02-23 22:06 ` Mehdi Saada [this message]
2021-02-24 9:59 ` AdaMagica
2021-02-24 10:04 ` Jeffrey R. Carter
2021-02-24 14:11 ` Simon Wright
2021-02-24 15:57 ` Shark8
2021-02-25 0:13 ` Mehdi Saada
2021-02-25 8:58 ` AdaMagica
2021-02-25 10:25 ` Mehdi Saada
2021-02-25 10:28 ` Mehdi Saada
2021-02-22 10:35 ` Jeffrey R. Carter
2021-02-22 14:21 ` Mehdi Saada
2021-02-22 15:02 ` Jeffrey R. Carter
2021-02-22 15:08 ` J-P. Rosen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox