From: reinert <reinkor@gmail.com>
Subject: Re: Compiler error (2) ?
Date: Mon, 26 Sep 2022 01:47:13 -0700 (PDT) [thread overview]
Message-ID: <4f8e27ad-03d7-400f-9901-92856e71f9d2n@googlegroups.com> (raw)
In-Reply-To: <tgro67$3mod2$1@dont-email.me>
This is what I (also) get:
test1a.adb:16:42: error: expected type "Standard.Integer"
test1a.adb:16:42: error: found type "Ada.Containers.Count_Type"
compilation of test1a.adb failed
gprbuild: *** compilation phase failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/reinert/test1a/test1a.gpr"] exited with code 4
error: Compilation failed.
---------------------------------------------------------------------------------------------------
**However, the following version goes through the compiler and runs
(using "subtype n_t is Positive range 3..Positive'Last;" for)
in the package specification) - confirming what Simon says:
with Ada.Text_IO;
with Ada.Containers.Vectors;
procedure test1a is
type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
for s_name_type use
(S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
subtype n_t is Positive range 3..Positive'Last;
package s_names_p is new Ada.Containers.Vectors
(Index_Type => n_t, Element_Type => s_name_type);
k : integer := 7;
n : constant integer := 7;
-- n : constant integer := k; -- uncomment this line and comment out the line above.
s_names: constant s_names_p.Vector := [for i in 3..n => S0];
begin
Ada.Text_IO.Put_Line(s_names'Image);
end test1a;
reinert
mandag 26. september 2022 kl. 10:34:18 UTC+2 skrev J-P. Rosen:
> Please give the exact error message, and why you think it could be a
> compiler error. Otherwise, it's hard to help...
> Le 26/09/2022 à 08:54, reinert a écrit :
> > Hello,
> >
> > This must reveal a compiler error :
> > -------------------------------------------------------------------------------------------------------
> > with Ada.Text_IO;
> > with Ada.Containers.Vectors;
> > procedure test1a is
> > type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
> > for s_name_type use
> > (S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
> > S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
> > package s_names_p is new Ada.Containers.Vectors
> > (Index_Type => Positive, Element_Type => s_name_type);
> > k : integer := 7;
> >
> > -- n : constant integer := 7; -- uncomment this line and comment out the line below.
> > n : constant integer := k;
> >
> > s_names: constant s_names_p.Vector := [for i in 3..n => S0];
> > begin
> > Ada.Text_IO.Put_Line(s_names'Image);
> > end test1a;
> > -------------------------------------------------------------------------------------------------------
> > (compiled using alire and
> > package Compiler is
> > for Switches ("ada") use ("-gnatwa", "-gnata", "-gnatX", "-gnatwv");
> > end Compiler;
> > -------------------------------------------------------------------------------------------------------
> >
> > Right?
> >
> > reinert
> --
> J-P. Rosen
> Adalog
> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> Tel: +33 1 45 29 21 52
> https://www.adalog.fr
next prev parent reply other threads:[~2022-09-26 8:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-26 6:54 Compiler error (2) ? reinert
2022-09-26 8:12 ` Simon Wright
2022-09-26 8:34 ` J-P. Rosen
2022-09-26 8:47 ` reinert [this message]
2022-09-26 9:59 ` reinert
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox