{
-- This is a test of semantic checking for procedures
--
-- you will need to run this several times, with some lines commented out
-- to see that you catch all the errors
}
$c+
module test20 { check semantics of procedures}
private
	integer i, res;
	tuple [procedure factorial(reference integer res)] fac;
	procedure fac@factorial
		integer j;
		
		tuple [procedure j(reference integer result), {ok}
		 procedure j(), { name conflict already defined here}
		 procedure i(reference integer res), { not defined later }
		 procedure times(reference integer result)
		] tester;
				
		procedure tester@times(reference integer result) {repeated params}
		begin
		   i := i*j; 
		   if j # i ->	j := j+1;
		   tester!times(); {wrong number of arguments}
		   []  j = i -> skip;
		   fi;
		   tester!fubar(result); { not declared or defined}
		end;
		
		procedure tester@junk { not declared }
		begin
			skip;
		end;
		
	begin { body of factorial}
	  j := 1;
	  tester!times(j, res); {wrong number of arguments}
	end;  { error no body for i;}
	
begin { module body}
	i := 6;
	fac!factorial(i); {ok}
end.

