From 810ee0f49e0a0949c6850d4618e41dee7347f209 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 30 Sep 2019 18:36:05 +0300 Subject: [PATCH] JS: fix crash on some JavaScript constructs in hand-written runtime code --- .../teavm/backend/javascript/rendering/AstVisitor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/AstVisitor.java b/core/src/main/java/org/teavm/backend/javascript/rendering/AstVisitor.java index b34bfcac1..54232cddc 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/AstVisitor.java +++ b/core/src/main/java/org/teavm/backend/javascript/rendering/AstVisitor.java @@ -29,6 +29,7 @@ import org.mozilla.javascript.ast.ConditionalExpression; import org.mozilla.javascript.ast.ContinueStatement; import org.mozilla.javascript.ast.DoLoop; import org.mozilla.javascript.ast.ElementGet; +import org.mozilla.javascript.ast.EmptyExpression; import org.mozilla.javascript.ast.EmptyStatement; import org.mozilla.javascript.ast.ExpressionStatement; import org.mozilla.javascript.ast.ForInLoop; @@ -133,7 +134,11 @@ public class AstVisitor { visitParenthesized((ParenthesizedExpression) node); break; case Token.EMPTY: - visitEmpty((EmptyStatement) node); + if (node instanceof EmptyStatement) { + visitEmpty((EmptyStatement) node); + } else { + visitEmpty((EmptyExpression) node); + } break; case Token.EXPR_VOID: case Token.EXPR_RESULT: @@ -377,6 +382,9 @@ public class AstVisitor { protected void visitEmpty(EmptyStatement node) { } + protected void visitEmpty(EmptyExpression node) { + } + protected void visitName(Name node) { }