diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e11c32b..e143468c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. - Using new FFDec icon on Mac - AS3: get/set slot for global scope - Better continue in for / goto detection +- AS3: Incorrect handling of strict equals operator in if vs switch resulting in §§pop ### Changed - AS3 test methods separated to classes diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index e4d1286d4..499f6e9a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -537,9 +537,7 @@ public class AVM2Graph extends Graph { switchedObject = new LocalRegAVM2Item(null, null, rightReg, null); } - if(leftReg < 0 && rightReg < 0){ - - } else if (cnt == 1) { + if ((leftReg < 0 && rightReg < 0) || (cnt == 1)) { stack.push(set); } else { part = part.nextParts.get(1); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java index e2f86f2b4..4cfd1ff46 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -910,6 +910,16 @@ public class ActionScript3Test extends ActionScriptTestBase { false); } + @Test + public void testStrictEquals() { + decompileMethod("testStrictEquals", "var k:int = 6;\r\n" + + "if(this.f() !== this.f())\r\n" + + "{\r\n" + + "trace(\"is eight\");\r\n" + + "}\r\n", + false); + } + @Test public void testStringConcat() { decompileMethod("testStringConcat", "var k:int = 8;\r\n" diff --git a/libsrc/ffdec_lib/testdata/flashdevelop/bin/flashdevelop.swf b/libsrc/ffdec_lib/testdata/flashdevelop/bin/flashdevelop.swf index e05772276..62b1f8ae6 100644 Binary files a/libsrc/ffdec_lib/testdata/flashdevelop/bin/flashdevelop.swf and b/libsrc/ffdec_lib/testdata/flashdevelop/bin/flashdevelop.swf differ diff --git a/libsrc/ffdec_lib/testdata/flashdevelop/src/Main.as b/libsrc/ffdec_lib/testdata/flashdevelop/src/Main.as index 3d9031bfa..cd5c728f1 100644 --- a/libsrc/ffdec_lib/testdata/flashdevelop/src/Main.as +++ b/libsrc/ffdec_lib/testdata/flashdevelop/src/Main.as @@ -59,6 +59,7 @@ package TestProperty; TestRegExp; TestRest; + TestStrictEquals; TestStringConcat; TestStrings; TestSwitch; diff --git a/libsrc/ffdec_lib/testdata/flashdevelop/src/tests/TestStrictEquals.as b/libsrc/ffdec_lib/testdata/flashdevelop/src/tests/TestStrictEquals.as new file mode 100644 index 000000000..fa2171090 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/flashdevelop/src/tests/TestStrictEquals.as @@ -0,0 +1,21 @@ +package tests +{ + + public class TestStrictEquals + { + + public function run() : void + { + var k:int = 6; + if (this.f() !== this.f()){ + trace("is eight"); + } + } + + private function f():String { + return "x"; + } + + } + +} \ No newline at end of file