Modify

#1677 closed Bug (Fixed)

ContinueLoop multiple level unpredictable behavior

Reported by: Ascend4nt Owned by: Jpm
Milestone: 3.3.7.0 Component: AutoIt
Version: 3.3.6.0 Severity: None
Keywords: ContinueLoop multiple levels Cc:

Description

Hi, I've recently had a WEIRD issue pop up in my code - I kept getting a "Variable used without being declared" error. It turns out the issue has to do with ContinueLoop on multiple levels (ContinueLoop #).

Since I removed the inner loop and forgot to remove the '2' from ContinueLoop, it was jumping to another loop. However, here's the funky thing - the OTHER loop was in another function! (in this case, the calling function).

I've successfully reproduced the issue here:

Func TestContinueLoopIssue($iValue)
	While 1
		If $iValue Then
			ContinueLoop 2
		EndIf
	Wend
EndFunc

Func OuterFunc()
	Local $iVal=5
	While 1
		$iVal+=1
		ConsoleWrite("OuterFunc $iVal="&$iVal&@CRLF)
		If $iVal>1000 Then ExitLoop
		TestContinueLoopIssue($iVal)
	WEnd
EndFunc

OuterFunc()

Output:
OuterFunc $iVal=6
C:\testscript.au3 (12) : ==> Variable used without being declared.:
$iVal+=1
ERROR
->05:51:17 AutoIT3.exe ended.rc:1

As you can see, it seems to 'continue' the loop in the calling function - but since the variable is local to that function, it will not recognize them, thus the crash.

Attachments (0)

Change History (7)

comment:1 by MrCreatoR <mscreator@…>, on Jun 16, 2010 at 7:14:52 PM

Really weird, it should throw an error on the ContinueLoop 2, because there only one loop.

And btw, there is another, and not less weird behaviour - if we add Local $iVal to the begining of TestContinueLoopIssue function, we got Recursion level error:

Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.

so it seems that when «ContinueLoop 2» is executed, it's calling the parent function (the continuation of it's loop) but still runing the current loop.

And if we add Global $iVal before we calling the OuterFunc() the script is crashed without any messages (Exit code: -1073741819).

comment:2 by Jpm, on Jun 17, 2010 at 6:45:58 PM

Milestone: 3.3.7.0
Owner: set to Jpm
Resolution: Fixed
Status: newclosed

Fixed by revision [5885] in version: 3.3.7.0

comment:3 by Jpm, on Jun 10, 2011 at 9:27:33 PM

Resolution: Fixed
Status: closedreopened

comment:4 by TicketCleanup, on Jun 11, 2011 at 12:00:01 AM

Milestone: 3.3.7.0

Automatic ticket cleanup.

comment:5 by Jpm, on Jun 14, 2011 at 2:28:51 PM

Resolution: Fixed
Status: reopenedclosed

Wrong reopening

comment:6 by TicketCleanup, on Jun 14, 2011 at 3:00:02 PM

Milestone: Future Release

Automatic ticket cleanup.

comment:7 by Jpm, on Feb 9, 2012 at 3:21:36 PM

Milestone: Future Release3.3.7.0

Modify Ticket

Action
as closed The owner will remain Jpm.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.