Skip to content

Commit

Permalink
EASY: printChild() should skip null nodes
Browse files Browse the repository at this point in the history
Summary:
`printChild()` can occasionally be called with a null node. Do nothing
in that case.

Reviewed By: neildhar

Differential Revision: D25452839

fbshipit-source-id: c2c2e148e2903c18ff473f06d6988a8876ebc32d
  • Loading branch information
tmikov authored and facebook-github-bot committed Dec 10, 2020
1 parent 883bb94 commit 2cfee04
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/AST2JS/AST2JS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ class GenJS {
}

void printChild(Node *child, Node *parent, ChildPos childPosition) {
if (!child)
return;
printParens(child, parent, needParens(parent, child, childPosition));
}

Expand Down
1 change: 1 addition & 0 deletions test/AST2JS/input1-p.js.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ do
while (i < 10);
for(a in b in c)
++a;
for(;;) {}
try {
1;
} catch (e) {}
Expand Down
1 change: 1 addition & 0 deletions test/AST2JS/input1.js.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ while (i < 10);

for(a in b in c)
++a;
for(;;) {}

try { 1; } catch (e) {}

Expand Down

0 comments on commit 2cfee04

Please sign in to comment.