Fixed Avoid Error Implicit coercion of a value of type XXX to an unrelated type YYY

This commit is contained in:
Jindra Petřík
2022-11-27 16:28:40 +01:00
parent a99df959bc
commit c26030620f
10 changed files with 77 additions and 5 deletions

View File

@@ -1031,6 +1031,23 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
false);
}
@Test
public void testImplicitCoerce() {
decompileMethod("classic_air", "testImplicitCoerce", "var j:int = 2;\r\n"
+ "var i:int = 5;\r\n"
+ "var r:* = Math.random();\r\n"
+ "if(j & Number(r == 1) && 5)\r\n"
+ "{\r\n"
+ "trace(\"OK\");\r\n"
+ "}\r\n"
+ "var s:String = \"hello: \" + r;\r\n"
+ "if(s)\r\n"
+ "{\r\n"
+ "trace(\"F\");\r\n"
+ "}\r\n",
false);
}
@Test
public void testImportedVar() {
decompileMethod("classic_air", "testImportedVar", "trace(myvar);\r\n"

View File

@@ -1026,6 +1026,23 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
false);
}
@Test
public void testImplicitCoerce() {
decompileMethod("classic", "testImplicitCoerce", "var j:int = 2;\r\n"
+ "var i:int = 5;\r\n"
+ "var r:* = Math.random();\r\n"
+ "if(Boolean(j & Number(r == 1)) && Boolean(5))\r\n"
+ "{\r\n"
+ "trace(\"OK\");\r\n"
+ "}\r\n"
+ "var s:String = \"hello: \" + r;\r\n"
+ "if(Boolean(s))\r\n"
+ "{\r\n"
+ "trace(\"F\");\r\n"
+ "}\r\n",
false);
}
@Test
public void testImportedVar() {
decompileMethod("classic", "testImportedVar", "trace(myvar);\r\n"