Modify

Opened 15 years ago

Closed 14 years ago

Last modified 13 years ago

#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 Changed 15 years ago by MrCreatoR <mscreator@…>

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 Changed 15 years ago by Jpm

  • Milestone set to 3.3.7.0
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5885] in version: 3.3.7.0

comment:3 Changed 14 years ago by Jpm

  • Resolution Fixed deleted
  • Status changed from closed to reopened

comment:4 Changed 14 years ago by TicketCleanup

  • Milestone 3.3.7.0 deleted

Automatic ticket cleanup.

comment:5 Changed 14 years ago by Jpm

  • Resolution set to Fixed
  • Status changed from reopened to closed

Wrong reopening

comment:6 Changed 14 years ago by TicketCleanup

  • Milestone set to Future Release

Automatic ticket cleanup.

comment:7 Changed 13 years ago by Jpm

  • Milestone changed from Future Release to 3.3.7.0

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.