Skip to content

Commit 2b0329d

Browse files
fix: don't add unnecessary noop
1 parent 6e63a00 commit 2b0329d

17 files changed

+1348
-78
lines changed

src/ast.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,15 @@ AST.prototype.resolvePrecedence = function(result, parser) {
323323
result = buffer;
324324
}
325325
}
326-
} else if (
327-
result.kind === "silent" &&
328-
!result.expr.parenthesizedExpression
329-
) {
330-
if (result.expr.kind === 'assign') return result;
326+
} else if (result.kind === "silent" && !result.expr.parenthesizedExpression) {
327+
if (result.expr.kind === "assign") return result;
331328
// overall least precedence
332329
if (result.expr.right) {
333330
buffer = result.expr;
334331
result.expr = buffer.left;
335332
buffer.left = result;
336333
this.swapLocations(buffer, buffer.left, buffer.right, parser);
337-
result = buffer;
334+
result = buffer;
338335
}
339336
}
340337
return result;

src/parser/array.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ module.exports = {
6464
*/
6565
read_array_pair: function(shortForm) {
6666
if (
67-
this.token === "," ||
6867
(!shortForm && this.token === ")") ||
6968
(shortForm && this.token === "]")
7069
) {
70+
return;
71+
}
72+
if (this.token === ",") {
7173
return this.node("noop")();
7274
}
7375
if (this.token === "&") {

src/parser/utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ module.exports = {
4040
break;
4141
}
4242
if (this.next().token == ")" && this.php73) {
43-
result.push(this.node("noop")());
4443
break;
4544
}
4645
} while (this.token != this.EOF);
@@ -65,7 +64,10 @@ module.exports = {
6564

6665
if (typeof item === "function") {
6766
do {
68-
result.push(item.apply(this, []));
67+
const itemResult = item.apply(this, []);
68+
if (itemResult) {
69+
result.push(itemResult);
70+
}
6971
if (this.token != separator) {
7072
break;
7173
}

0 commit comments

Comments
 (0)