#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 , 16 years ago
comment:2 by , 16 years ago
| Milestone: | → 3.3.7.0 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [5885] in version: 3.3.7.0
comment:3 by , 15 years ago
| Resolution: | Fixed |
|---|---|
| Status: | closed → reopened |
comment:7 by , 14 years ago
| Milestone: | Future Release → 3.3.7.0 |
|---|

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:
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).