(BUG) Loop counter initialisation

Community Forums/Monkey2 Talk/(BUG) Loop counter initialisation

impixi(Posted 2016) [#1]
V005.

There's a bug with loop counter initialisation if the counter is declared outside the loop. The following code should demonstrate the problem:

#Import "<std.monkey2>"

Using std..

Function Main()
	
	Print "~n---~nVariable declared outside loops~n---~n"
	
	Local i:Int
	
	For i = 0 Until 4
		Print i
	Next
	
	'i should be initialized to 10 at the start of this loop but it is not.
	For i = 10 Until 14
		Print i
	Next
	
	Print "~n---~nVariables declared local to loops~n---~n"
	
	For Local idx := 0 Until 4
		Print idx
	Next
	
	For Local idx := 10 Until 14
		Print idx
	next

End