Skip to content

Commit 62973ef

Browse files
authored
Merge pull request #367 from glayzzle/issue-358
fix: don't add unnecessary `noop`
2 parents 2cb5e99 + 9dbc304 commit 62973ef

16 files changed

+1343
-72
lines changed

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)