mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-08-02 15:32:15 +00:00
Fixed #1006 AS3 - Warning - Function value used where type Boolean was expected
as3_new testdata compilers do not ignore warnings as3_new testdata without warnings
This commit is contained in:
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Tag dependency checking
|
||||
- [#1884] Memory search - Logged exception when cannot get page range
|
||||
- [#1884] Memory search - Exception on sorting by pid
|
||||
- [#1006] AS3 - Warning - Function value used where type Boolean was expected
|
||||
|
||||
### Changed
|
||||
- Quick search needs minimum of 3 characters
|
||||
@@ -2697,6 +2698,7 @@ All notable changes to this project will be documented in this file.
|
||||
[#1765]: https://www.free-decompiler.com/flash/issues/1765
|
||||
[#1884]: https://www.free-decompiler.com/flash/issues/1884
|
||||
[#1897]: https://www.free-decompiler.com/flash/issues/1897
|
||||
[#1006]: https://www.free-decompiler.com/flash/issues/1006
|
||||
[#1888]: https://www.free-decompiler.com/flash/issues/1888
|
||||
[#1895]: https://www.free-decompiler.com/flash/issues/1895
|
||||
[#1896]: https://www.free-decompiler.com/flash/issues/1896
|
||||
|
||||
@@ -347,7 +347,7 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
if (!t.returnType().equals(TypeItem.UNBOUNDED) &&
|
||||
!implicitCoerce.equals(returnTypeStr) &&
|
||||
!(numberTypes.contains(implicitCoerce) && numberTypes.contains(returnTypeStr)) &&
|
||||
!(implicitCoerce.equals("Boolean"))
|
||||
!(implicitCoerce.equals("Boolean") && !returnTypeStr.equals("Function"))
|
||||
) {
|
||||
t = new ConvertAVM2Item(null, null, t, new TypeItem(implicitCoerce));
|
||||
}
|
||||
|
||||
@@ -222,13 +222,17 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
decompileMethod("classic_air", "testConvert", "var s:* = null;\r\n"
|
||||
+ "var i:int = 0;\r\n"
|
||||
+ "var a:* = undefined;\r\n"
|
||||
+ "s = \"a\";\r\n"
|
||||
+ "i = int(s);\r\n"
|
||||
+ "var j:int;\r\n"
|
||||
+ "s = String(j = n);\r\n"
|
||||
decompileMethod("classic_air", "testConvert", "var a:*;\r\n"
|
||||
+ "var o:Object;\r\n"
|
||||
+ "var v:Vector.<String>;\r\n"
|
||||
+ "var x:XML;\r\n"
|
||||
+ "var xlist:XMLList;\r\n"
|
||||
+ "var lc:LocalClass;\r\n"
|
||||
+ "var f:Function;\r\n"
|
||||
+ "var s:String = \"a\";\r\n"
|
||||
+ "var i:int = s;\r\n"
|
||||
+ "var j:int = n;\r\n"
|
||||
+ "s = String(j);\r\n"
|
||||
+ "s = ns;\r\n"
|
||||
+ "s = String(i == 4 ? \"\" : i);\r\n"
|
||||
+ "s = i == 4 ? \"\" : String(i);\r\n"
|
||||
@@ -237,13 +241,13 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
+ "i = 4 * 5;\r\n"
|
||||
+ "i = a * 6;\r\n"
|
||||
+ "i = a;\r\n"
|
||||
+ "var o:Object = {\r\n"
|
||||
+ "o = {\r\n"
|
||||
+ "0:\"A\",\r\n"
|
||||
+ "1:\"B\",\r\n"
|
||||
+ "2:\"C\"\r\n"
|
||||
+ "};\r\n"
|
||||
+ "i = int(s.charAt(10));\r\n"
|
||||
+ "var v:Vector.<String> = new Vector.<String>();\r\n"
|
||||
+ "v = new Vector.<String>();\r\n"
|
||||
+ "v.push(\"A\");\r\n"
|
||||
+ "v.push(\"B\");\r\n"
|
||||
+ "i = int(v[0]);\r\n"
|
||||
@@ -253,21 +257,40 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
+ "i = int(prot);\r\n"
|
||||
+ "s = prot;\r\n"
|
||||
+ "s = String(getTimer());\r\n"
|
||||
+ "var x:XML;\r\n"
|
||||
+ "s = x = <list>\r\n"
|
||||
+ "x = <list>\r\n"
|
||||
+ "<item id=\"1\">1</item>\r\n"
|
||||
+ "<item id=\"2\">2</item>\r\n"
|
||||
+ "<item id=\"3\">3</item>\r\n"
|
||||
+ "</list>;\r\n"
|
||||
+ "s = x;\r\n"
|
||||
+ "trace(\"a\");\r\n"
|
||||
+ "var xlist:XMLList = x.item;\r\n"
|
||||
+ "xlist = x.item;\r\n"
|
||||
+ "trace(\"b\");\r\n"
|
||||
+ "i = int(xlist[i].@id);\r\n"
|
||||
+ "trace(\"c\");\r\n"
|
||||
+ "i = int(x.item[i].@id);\r\n"
|
||||
+ "var lc:LocalClass;\r\n"
|
||||
+ "i = (lc = new LocalClass()).attr;\r\n"
|
||||
+ "s = String(lc.attr);\r\n",
|
||||
+ "lc = new LocalClass();\r\n"
|
||||
+ "i = lc.attr;\r\n"
|
||||
+ "s = String(lc.attr);\r\n"
|
||||
+ "f = function():void\r\n"
|
||||
+ "{\r\n"
|
||||
+ "};\r\n"
|
||||
+ "if(Boolean(f))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"OK\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(i)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(i);\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(s)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(s);\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(o)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"obj\");\r\n"
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -613,14 +636,12 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
|
||||
@Test
|
||||
public void testForEachReturn2() {
|
||||
decompileMethod("classic_air", "testForEachReturn2", "var item:* = undefined;\r\n"
|
||||
+ "var obj:* = null;\r\n"
|
||||
decompileMethod("classic_air", "testForEachReturn2", "var obj:* = null;\r\n"
|
||||
+ "var x:int = 5;\r\n"
|
||||
+ "if(x != null)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "obj = {};\r\n"
|
||||
+ "item = {};\r\n"
|
||||
+ "for each(item in obj)\r\n"
|
||||
+ "for each(var item in obj)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "switch(item[\"key\"])\r\n"
|
||||
+ "{\r\n"
|
||||
@@ -1653,9 +1674,9 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
decompileMethod("classic_air", "testUndefined", "var i:int;\r\n"
|
||||
+ "var j:int;\r\n"
|
||||
+ "var c:int;\r\n"
|
||||
+ "var f:*;\r\n"
|
||||
+ "var f:Function;\r\n"
|
||||
+ "c = 5 + i;\r\n"
|
||||
+ "f = function():*\r\n"
|
||||
+ "f = function():void\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(c);\r\n"
|
||||
+ "trace(j);\r\n"
|
||||
|
||||
@@ -221,7 +221,11 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
decompileMethod("classic", "testConvert", "var s:String = null;\r\n"
|
||||
decompileMethod("classic", "testConvert", "var x:XML;\r\n"
|
||||
+ "var xlist:XMLList;\r\n"
|
||||
+ "var lc:LocalClass;\r\n"
|
||||
+ "var f:Function;\r\n"
|
||||
+ "var s:String = null;\r\n"
|
||||
+ "var i:int = 0;\r\n"
|
||||
+ "var a:* = undefined;\r\n"
|
||||
+ "s = \"a\";\r\n"
|
||||
@@ -252,21 +256,40 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
+ "i = int(prot);\r\n"
|
||||
+ "s = prot;\r\n"
|
||||
+ "s = String(getTimer());\r\n"
|
||||
+ "var x:XML = <list>\r\n"
|
||||
+ "x = <list>\r\n"
|
||||
+ "<item id=\"1\">1</item>\r\n"
|
||||
+ "<item id=\"2\">2</item>\r\n"
|
||||
+ "<item id=\"3\">3</item>\r\n"
|
||||
+ "</list>;\r\n"
|
||||
+ "s = x;\r\n"
|
||||
+ "trace(\"a\");\r\n"
|
||||
+ "var xlist:XMLList = x.item;\r\n"
|
||||
+ "xlist = x.item;\r\n"
|
||||
+ "trace(\"b\");\r\n"
|
||||
+ "i = int(xlist[i].@id);\r\n"
|
||||
+ "trace(\"c\");\r\n"
|
||||
+ "i = int(x.item[i].@id);\r\n"
|
||||
+ "var lc:LocalClass = new LocalClass();\r\n"
|
||||
+ "lc = new LocalClass();\r\n"
|
||||
+ "i = lc.attr;\r\n"
|
||||
+ "s = String(lc.attr);\r\n",
|
||||
+ "s = String(lc.attr);\r\n"
|
||||
+ "f = function():void\r\n"
|
||||
+ "{\r\n"
|
||||
+ "};\r\n"
|
||||
+ "if(Boolean(f))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"OK\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(Boolean(i))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(i);\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(Boolean(s))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(s);\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(Boolean(o))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"obj\");\r\n"
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -609,22 +632,21 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testForEachReturn2() {
|
||||
decompileMethod("classic", "testForEachReturn2", "var _loc3_:* = undefined;\r\n"
|
||||
+ "var _loc1_:* = null;\r\n"
|
||||
+ "var _loc2_:* = 5;\r\n"
|
||||
+ "if(_loc2_ != null)\r\n"
|
||||
decompileMethod("classic", "testForEachReturn2", "var item:* = undefined;\r\n"
|
||||
+ "var obj:* = null;\r\n"
|
||||
+ "var x:* = 5;\r\n"
|
||||
+ "if(x != null)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "_loc1_ = {};\r\n"
|
||||
+ "_loc3_ = {};\r\n"
|
||||
+ "for each(_loc3_ in _loc1_)\r\n"
|
||||
+ "obj = {};\r\n"
|
||||
+ "for each(item in obj)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "switch(_loc3_[\"key\"])\r\n"
|
||||
+ "switch(item[\"key\"])\r\n"
|
||||
+ "{\r\n"
|
||||
+ "case 1:\r\n"
|
||||
+ "case 2:\r\n"
|
||||
+ "case 3:\r\n"
|
||||
+ "case 4:\r\n"
|
||||
+ "return _loc3_;\r\n"
|
||||
+ "return item;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
@@ -1653,7 +1675,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
+ "var j:int = 0;\r\n"
|
||||
+ "var c:int = 0;\r\n"
|
||||
+ "c = 5 + i;\r\n"
|
||||
+ "var f:* = function():*\r\n"
|
||||
+ "var f:Function = function():void\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(c);\r\n"
|
||||
+ "trace(j);\r\n"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
@echo off
|
||||
set COMPILERKIND=air
|
||||
set SWFNAME=as3_new
|
||||
call c:\air\bin\mxmlc.bat -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
|
||||
call c:\air\bin\mxmlc.bat -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
|
||||
rem -warnings=false
|
||||
@@ -1,4 +1,5 @@
|
||||
@echo off
|
||||
set COMPILERKIND=flex
|
||||
set SWFNAME=as3_new
|
||||
c:\flex\bin\mxmlc.exe -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
|
||||
c:\flex\bin\mxmlc.exe -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
|
||||
rem -warnings=false
|
||||
@@ -6,8 +6,8 @@ package tests
|
||||
{
|
||||
public function run() : *
|
||||
{
|
||||
var o = new getDefinitionByName("Object")();
|
||||
var o2 = new (getDefinitionByName("Object"))();
|
||||
var o:* = new getDefinitionByName("Object")();
|
||||
var o2:* = new (getDefinitionByName("Object"))();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,24 @@ package tests
|
||||
|
||||
var lc:LocalClass = new LocalClass();
|
||||
i = lc.attr;
|
||||
s = String(lc.attr);
|
||||
s = String(lc.attr);
|
||||
|
||||
|
||||
var f:Function = function():void {};
|
||||
if (Boolean(f)) {
|
||||
trace("OK");
|
||||
}
|
||||
|
||||
if (i) {
|
||||
trace(i);
|
||||
}
|
||||
if (s) {
|
||||
trace(s);
|
||||
}
|
||||
|
||||
if (o) {
|
||||
trace("obj");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,11 @@ package tests
|
||||
public function run():*
|
||||
{
|
||||
var obj:* = null;
|
||||
var x = 5;
|
||||
var x:* = 5;
|
||||
if (x != null)
|
||||
{
|
||||
obj = {};
|
||||
var item = {};
|
||||
for each (var item in obj)
|
||||
for each (var item:* in obj)
|
||||
{
|
||||
switch (item["key"])
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ package tests
|
||||
{
|
||||
public function run():*
|
||||
{
|
||||
trace("hello");
|
||||
trace("hello");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ package tests
|
||||
{
|
||||
myInternal var neco:int;
|
||||
myInternal2 var neco:int;
|
||||
var nic:int;
|
||||
internal var nic:int;
|
||||
|
||||
public function run():*
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ package tests
|
||||
var i:int;
|
||||
var j:int
|
||||
var c:int = 5 + i;
|
||||
var f = function() {
|
||||
var f:Function = function(): void {
|
||||
trace(c);
|
||||
trace(j);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user