fix if_return on AST_Defun (#2010)

Previous fiix for #1052 perturbs declaration order of functions which leads to incorrect behaviour under "use strict".
This commit is contained in:
Alex Lam S.L
2017-05-27 13:41:49 +08:00
committed by GitHub
parent 1ff8e9dd38
commit 95094b9c22
2 changed files with 69 additions and 23 deletions

View File

@@ -965,15 +965,15 @@ merge(Compressor.prototype, {
CHANGED = true;
stat = stat.clone();
stat.condition = stat.condition.negate(compressor);
var funs = extract_functions_from_statement_array(ret);
var body = as_statement_array(stat.alternative).concat(ret);
var funs = extract_functions_from_statement_array(body);
stat.body = make_node(AST_BlockStatement, stat, {
body: body
});
stat.alternative = value ? make_node(AST_SimpleStatement, value, {
body: value.expression
}) : null;
ret = funs.concat([ stat.transform(compressor) ]);
ret = [ stat.transform(compressor) ].concat(funs);
continue loop;
}
//---