浏览代码

LibJS: Don't try to parse binding patterns after a syntax error

Otherwise we'd be spinning there forever.
Ali Mohammad Pur 4 年之前
父节点
当前提交
e10006b3fa
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      Userland/Libraries/LibJS/Parser.cpp

+ 2 - 0
Userland/Libraries/LibJS/Parser.cpp

@@ -1482,6 +1482,7 @@ RefPtr<BindingPattern> Parser::parse_binding_pattern()
                 consume();
                 consume();
                 if (!match(TokenType::Identifier)) {
                 if (!match(TokenType::Identifier)) {
                     syntax_error("Expected a binding pattern as the value of a named element in destructuring object");
                     syntax_error("Expected a binding pattern as the value of a named element in destructuring object");
+                    break;
                 } else {
                 } else {
                     auto identifier_start = position();
                     auto identifier_start = position();
                     auto token = consume(TokenType::Identifier);
                     auto token = consume(TokenType::Identifier);
@@ -1523,6 +1524,7 @@ RefPtr<BindingPattern> Parser::parse_binding_pattern()
                     syntax_error("Expected a binding pattern after ... in destructuring list");
                     syntax_error("Expected a binding pattern after ... in destructuring list");
                 else
                 else
                     syntax_error("Expected a binding pattern or identifier in destructuring list");
                     syntax_error("Expected a binding pattern or identifier in destructuring list");
+                break;
             } else {
             } else {
                 RefPtr<Expression> initializer;
                 RefPtr<Expression> initializer;
                 if (match(TokenType::Equals)) {
                 if (match(TokenType::Equals)) {