wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps

Home Page:https://wurstlang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function calls as array index are executed twice when assignment shorthands are used

Jampi0n opened this issue · comments

A function call that is used as array index for assignment shorthands (+=, -=, ++, ...) is executed twice:
test[getIndex()]++ gets translated to test[getIndex()] = test[getIndex()] + 1
The function can return different values in each call and could also have side effects that are repeated.

The expected behavior would be to have a temporary variable which stores the return value and use that variable as index:

tmp = getIndex()
test[tmp] = test[tmp] + 1