HoriSun / closure-compiler

Automatically exported from code.google.com/p/closure-compiler
0 stars 0 forks source link

some functions are rewrite "return local_var=something" instead of "return something" #1246

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. echo "function f1(){var r='a'; r+=f2();return r;}" | java -jar 
/usr/share/java/gcmp/compiler.jar

What is the expected output? What do you see instead?
expected : function f1(){return "a"+f2()}
see instead  : function f1(){var a;return a="a"+f2()};

What version of the product are you using? On what operating system?
Version : compiler-20140110.zip
OS : Debian Wheezy

Please provide any additional information below.
In some case, instead of returning a value, some functions return the 
affectation to a local variable. The JS is correct, but we can expect the 
compiler to detect this optimisation.

Original issue reported on code.google.com by tdel...@gmail.com on 19 Feb 2014 at 2:21

GoogleCodeExporter commented 9 years ago
My guess is that FlowSensitiveInlineVariable happens after the loop that 
DeadAssignmentElimination runs in.

The fix is to run DeadAssignmentElimination right after it.

Original comment by acle...@gmail.com on 19 Feb 2014 at 9:03

GoogleCodeExporter commented 9 years ago

Original comment by acle...@gmail.com on 19 Feb 2014 at 11:07

GoogleCodeExporter commented 9 years ago
Issue tracking has been migrated to github. Please make any further comments on 
this issue through https://github.com/google/closure-compiler/issues

Original comment by blic...@google.com on 1 May 2014 at 6:31

GoogleCodeExporter commented 9 years ago

Original comment by blic...@google.com on 1 May 2014 at 6:34