--
-- This is a test of semantic checking for test 19.
--
package test20 is body
    a : integer;
    procedure factorial(x : in out integer; b : integer);
    -- forward declaration doesn't match body
    procedure factorial (a : in out integer; b : integer) is 
	procedure add (a : out integer; b, c : in integer);
	procedure times (a : out integer; b, c : in integer) is
	    i : integer;
	begin
	    i := 1;
	    loop
		add (a, a, c);
		exit when i == b;
	    end loop;
	end;
	-- forward declaration doesn't match body
	procedure add (a : out integer; b, c : in float) is begin
	    a := b + c;
	end;
    begin
	if b <> 0 then times (a, a, b); factorial (a, b - 1); end if;
    end;
begin 
    a := 1;
    factorial(a + 1, 4); -- first argument must be a variable (out)
    write ("factorial(4) = ", a, " (should be 24)");
end.
