From e10006b3fa3fc5b727c804f68da31a20b0fdbcc9 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 30 May 2021 01:58:28 +0430 Subject: [PATCH] LibJS: Don't try to parse binding patterns after a syntax error Otherwise we'd be spinning there forever. --- Userland/Libraries/LibJS/Parser.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 1364c207bd..12d4f10af1 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -1482,6 +1482,7 @@ RefPtr Parser::parse_binding_pattern() consume(); if (!match(TokenType::Identifier)) { syntax_error("Expected a binding pattern as the value of a named element in destructuring object"); + break; } else { auto identifier_start = position(); auto token = consume(TokenType::Identifier); @@ -1523,6 +1524,7 @@ RefPtr Parser::parse_binding_pattern() syntax_error("Expected a binding pattern after ... in destructuring list"); else syntax_error("Expected a binding pattern or identifier in destructuring list"); + break; } else { RefPtr initializer; if (match(TokenType::Equals)) {