Modify ↓
Opened on Jun 9, 2026 at 10:19:48 AM
Last modified on Jun 10, 2026 at 6:49:49 PM
#4103 new Bug
The expression in the array index was evaluated twice when assigning value
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description
Example code:
Local $i = -1
Func Inc()
$i += 1
ConsoleWrite("$i = " & $i & @CRLF)
Return $i
EndFunc
Local $a[5] = [0, 1, 2, 3, 4]
$a[Inc()] = "Test"
_DebugArrayDisplay($a, $i)
The result in console:
$i = 0 $i = 1
The result of array display:
Row|Col 0 # 0|0 # 1|Test # 2|2 # 3|3 # 4|4
The result of $i: 1
This bug only occurs when assigning value to the array ($a[Inc()] = "value"), but not when getting value ($value = $a[Inc()])
Attachments (0)
Note:
See TracTickets
for help on using tickets.

You right I remember similar pb
at that time the answer will not be fix due to the way the the interpreter is evaluating the subscript for array entry assignment
just change $a[Inc()] = "Test"
to
$i=Inc()
$a[$i] = "Test"