comp.lang.ada
 help / color / mirror / Atom feed
* Is this an error in compiler?
@ 2022-09-11  7:16 reinert
  0 siblings, 0 replies; 3+ messages in thread
From: reinert @ 2022-09-11  7:16 UTC (permalink / raw)


Hello,

I tried alire with the latest version of the compiler (I believe) and I got trouble
compiling this program (which I here have reduced just to communicate my point - i.e. the program has noe other meaning here):
--------------------------------------------------------------------------------------------
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Exceptions;
with Ada.Text_IO;       use Ada.Text_IO;

procedure c0a is

subtype String_1 is String (1 .. <>);

package cpros is
   cfe0,cfe1,cfe2 : exception;
   generic
      with procedure execute_command1 (command1 : String);
   procedure cpros0
     (file1 : in Ada.Text_IO.File_Type; command0 : String := "");
end cpros;

package body cpros is

   procedure cpros0 (file1 : in Ada.Text_IO.File_Type; command0 : String := "")
   is
   begin
       declare
          function rep1 (str0 : String_1) return String is
             i : constant Natural := Index (str0, "$");
          begin
             return str0 when i = 0;
             raise cfe2 with "(wrong use of '$')" when i = str0'Last;  -- a 
        --   if i = str0'Last then                                     -- b
        --      raise cfe2 with "(wrong use of '$')";                  -- b
        --   end if;                                                   -- b
             return "aaa";
          end rep1;
          str0 : constant String := rep1 (Get_Line (file1));
       begin
         null;
       end;
   end cpros0;
end cpros;

   procedure execute_command1 (str : String) is
   begin
     null;
   end execute_command1;

   procedure cpros1 is new cpros.cpros0 (execute_command1 => execute_command1);

begin
  null;
end c0a;
-----------------------------------------------------------------------------------------------
This goes through when I compile it.

However, if I  uncomment out the "a" line and comment out the "b" line (see code above), then I get the error message:

c0a.adb:45:04: error: instantiation error at line 27
c0a.adb:45:04: error: "cfe2" is not visible
c0a.adb:45:04: error: instantiation error at line 27
c0a.adb:45:04: error: non-visible declaration at line 10

Have you the same experience?

reinert



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Is this an error in compiler?
@ 2022-09-11  7:21 reinert
  0 siblings, 0 replies; 3+ messages in thread
From: reinert @ 2022-09-11  7:21 UTC (permalink / raw)


Hello,

I tried alire with the latest version of the compiler (I believe) and I got trouble
compiling this program (which I here have reduced just to communicate my point - i.e. the program has noe other meaning here):
--------------------------------------------------------------------------------------------
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;

procedure c0a is

subtype String_1 is String (1 .. <>);

package cpros is
cfe0,cfe1,cfe2 : exception;
generic
with procedure execute_command1 (command1 : String);
procedure cpros0
(file1 : in Ada.Text_IO.File_Type; command0 : String := "");
end cpros;

package body cpros is

procedure cpros0 (file1 : in Ada.Text_IO.File_Type; command0 : String := "")
is
begin
declare
function rep1 (str0 : String_1) return String is
i : constant Natural := Index (str0, "$");
begin
return str0 when i = 0;
-- raise cfe2 with "(wrong use of '$')" when i = str0'Last; -- a
if i = str0'Last then -- b
raise cfe2 with "(wrong use of '$')"; -- b
end if; -- b
return "aaa";
end rep1;
str0 : constant String := rep1 (Get_Line (file1));
begin
null;
end;
end cpros0;
end cpros;

procedure execute_command1 (str : String) is
begin
null;
end execute_command1;

procedure cpros1 is new cpros.cpros0 (execute_command1 => execute_command1);

begin
null;
end c0a;
-----------------------------------------------------------------------------------------------
This goes through when I compile it.

However, if I uncomment out the "a" line and comment out the "b" line (see code above), then I get the error message:

c0a.adb:45:04: error: instantiation error at line 27
c0a.adb:45:04: error: "cfe2" is not visible
c0a.adb:45:04: error: instantiation error at line 27
c0a.adb:45:04: error: non-visible declaration at line 10

Have you the same experience?

reinert

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Is this an error in compiler?
@ 2022-09-11  7:27 reinert
  0 siblings, 0 replies; 3+ messages in thread
From: reinert @ 2022-09-11  7:27 UTC (permalink / raw)


Hello,

I tried alire with the latest version of the compiler (I believe) and I got trouble
compiling this program (which I here have reduced just to communicate my 
point - i.e. the program has no other meaning here):
--------------------------------------------------------------------------------------------
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;

procedure c0a is

subtype String_1 is String (1 .. <>);

package cpros is
cfe0,cfe1,cfe2 : exception;
generic
with procedure execute_command1 (command1 : String);
procedure cpros0
(file1 : in Ada.Text_IO.File_Type; command0 : String := "");
end cpros;

package body cpros is

procedure cpros0 (file1 : in Ada.Text_IO.File_Type; command0 : String := "")
is
begin
declare
function rep1 (str0 : String_1) return String is
i : constant Natural := Index (str0, "$");
begin
return str0 when i = 0;
-- raise cfe2 with "(wrong use of '$')" when i = str0'Last; -- a
if i = str0'Last then -- b
raise cfe2 with "(wrong use of '$')"; -- b
end if; -- b
return "aaa";
end rep1;
str0 : constant String := rep1 (Get_Line (file1));
begin
null;
end;
end cpros0;
end cpros;

procedure execute_command1 (str : String) is
begin
null;
end execute_command1;

procedure cpros1 is new cpros.cpros0 (execute_command1 => execute_command1);

begin
null;
end c0a;
-----------------------------------------------------------------------------------------------
This goes through when I compile it.

However, if I uncomment the "a" line and comment out the alternative "b" line 
(see code above), then I get the error message:

c0a.adb:45:04: error: instantiation error at line 27
c0a.adb:45:04: error: "cfe2" is not visible
c0a.adb:45:04: error: instantiation error at line 27
c0a.adb:45:04: error: non-visible declaration at line 10

Have you the same experience?

reinert

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-11  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-11  7:16 Is this an error in compiler? reinert
  -- strict thread matches above, loose matches on Subject: below --
2022-09-11  7:21 reinert
2022-09-11  7:27 reinert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox