Modify

Opened 16 years ago

Closed 15 years ago

Last modified 14 years ago

#1677 closed Bug (Fixed)

ContinueLoop multiple level unpredictable behavior

Reported by: Ascend4nt Owned by: J-Paul Mesnage
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@…>, 16 years ago

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 J-Paul Mesnage, 16 years ago

Milestone: 3.3.7.0
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [5885] in version: 3.3.7.0

comment:3 by J-Paul Mesnage, 15 years ago

Resolution: Fixed
Status: closedreopened

comment:4 by TicketCleanup, 15 years ago

Milestone: 3.3.7.0

Automatic ticket cleanup.

comment:5 by J-Paul Mesnage, 15 years ago

Resolution: Fixed
Status: reopenedclosed

Wrong reopening

comment:6 by TicketCleanup, 15 years ago

Milestone: Future Release

Automatic ticket cleanup.

comment:7 by J-Paul Mesnage, 14 years ago

Milestone: Future Release3.3.7.0

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


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