Yes, this is an error player, another workaround would be to pass your result to int, so the command generated by the compiler will not be like this:
In the first case:
function testFunc(val1:int, val2:int, val3:int):int { var returnVal:int = 0; return returnVal; }
the compiler generates something like this: Note that there is nothing wrong with the generated code
getlocal 0 pushscope pushbyte 0 // stack = 0 dup // stack = 0 0 setlocal 4 // set returnVal with value on stack, stack = 0 returnvalue // return the value left on the stack ie 0, stack=empty
and for a workaround:
function testFunc(val1:int, val2:int, val3:int):int { var returnVal:int = 0; return int(returnVal); }
generated code
getlocal 0 pushscope pushbyte 0 // stack = 0 setlocal 4 // set returnValue with the value on the stack, stack=empty findpropstrict int // push on stack the object holding the int property, stack=object getlocal 4 // push on stack returnVal, stack=object 0 callproperty int(param count:1) // call the int property , stack=0 returnvalue // return the value left on stack ie 0, stack=empty
source share