If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler
NEW : We have got a new blog where we post some interesting SWF internals info.
List of issues#2573 Optimizer causes return of uint math to be of incorrect type
Author:
Zanzlanz
ZanzlanzDate created:
Type: bug
Visibility: Everybody
Assigned to:
Labels: AS3
State: upgraded 

> What steps will reproduce the problem?
Decompile an SWF with this code:
```function double(param:uint):* {
var sum:uint = param;
sum += param;
return sum;
}
trace(double(4294967295)); // The return is a uint of value 4294967294```
Notice the `convert_u` in the P-code when the sum is assigned:
```getlocal2
getlocal1
add
convert_u
setlocal2
getlocal2
returnvalue```
> What is the expected output? What do you see instead?
The decompiler does not take into account the `convert_u`, and outputs a different
number:
```public function double(param1:uint) : *
{
var _loc2_:uint = param1;
return _loc2_ + param1;
}
//...
trace(this.double(4294967295)); // Returns 8589934590```
The P-code for the decompiled output is lacking a `convert_u`:
```getlocal2
getlocal1
add
returnvalue```
The fix is to not combine the return statement with the previous operation, when an
implicit cast to uint is detected. Or, perhaps more optimally, simply cast the value
before returning in this case.
> What version of the product are you using? Is it "nightly build"? Which operating system
do you have?
Version: v.24.1.1
OS: Windows 11
> Please provide any additional information below. If the problem is related to a SWF
file, attach it here, otherwise we can't help you.
I've attached the SWF and FLA.
Note "4294967295" is the max uint; equivalent to using 0xFFFFFFFF. Other large values may
work as test cases.
unsigned_int_implicit_cast.swf (1 KiB)
unsigned_int_implicit_cast.fla (5 KiB)This is fixed in nightly 3350.
State: new→upgraded
