--* From PETEB%WATSON.vnet.ibm.com@yktvmv.watson.ibm.com  Sun Mar 13 19:49:17 1994
--* Received: from yktvmv.watson.ibm.com by leonardo.watson.ibm.com (AIX 3.2/UCB 5.64/920123)
--*           id AA19284; Sun, 13 Mar 1994 19:49:17 -0500
--* X-External-Networks: yes
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 0743; Sun, 13 Mar 94 19:48:56 EST
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.PETEB.NOTE.VAGENT2.5587.Mar.13.19:48:55.-0500>
--*           for asbugs@watson; Sun, 13 Mar 94 19:48:55 -0500
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id 5581; Sun, 13 Mar 1994 19:48:54 EST
--* Received: from hydride.watson.ibm.com by yktvmv.watson.ibm.com
--*    (IBM VM SMTP V2R3) with TCP; Sun, 13 Mar 94 19:48:52 EST
--* Received: by hydride.watson.ibm.com (4.1/930317)
--*           id AA16350; Sun, 13 Mar 94 19:48:48 EST
--* Date: Sun, 13 Mar 94 19:48:48 EST
--* From: peteb@hydride.watson.ibm.com (Peter A. Broadbery)
--* Message-Id: <9403140048.AA16350@hydride.watson.ibm.com>
--* To: asbugs@watson.ibm.com
--* Subject: [4] where0.as compiled with -O gives bad output [where0.as][v34.4]

--@ Fixed  by:  PI   Tue Nov 8 11:22:55 EST 1994 
--@ Tested by:  none 
--@ Summary:    The correct output is now produced by v0-37-0. 

--> testcomp
--> testgen l
--> testrun

#include "aslib.as"

import from SingleInteger

foo(): () ==
	print(x*x)() where
		x:SingleInteger == 2


foo()

print(x*x)() where
	x:SingleInteger == 5


bar(): () ==
	local
		f1: () -> SingleInteger
		f2: () -> SingleInteger
	for i in 1..2 repeat
		local x: () -> SingleInteger
		x := fun where
			local a: SingleInteger := i
			fun():SingleInteger == a+1
			baz():SingleInteger == fun()+1
			print(fun())()
			print(baz())()
		if (i = 1) then f1 := x
		if (i = 2) then f2 := x
		print(x())()
	print(f2())()
	print(f1())()

bar()
 
