var stat = statements[i];
var next = statements[i + 1];
- if (in_lambda && stat instanceof AST_Return && !stat.value && !next) {
- CHANGED = true;
- statements.length--;
- continue;
+ if (in_lambda && !next && stat instanceof AST_Return) {
+ if (!stat.value) {
+ CHANGED = true;
+ statements.length--;
+ continue;
+ }
+ if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
+ CHANGED = true;
+ statements[i] = make_node(AST_SimpleStatement, stat, {
+ body: stat.value.expression
+ });
+ continue;
+ }
}
if (stat instanceof AST_If) {
&& prev instanceof AST_If && prev.body instanceof AST_Return
&& i + 2 == statements.length && next instanceof AST_SimpleStatement) {
CHANGED = true;
- statements.push(make_node(AST_Return, next, {
- value: null
- }).transform(compressor));
+ stat = stat.clone();
+ stat.alternative = make_node(AST_BlockStatement, next, {
+ body: [
+ next,
+ make_node(AST_Return, next, {
+ value: null
+ })
+ ]
+ });
+ statements.splice(i, 2, stat.transform(compressor));
continue;
}
}