From cfb1b077cd505b4121554ed5b3f9456a66cb9a10 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Thu, 26 May 2022 22:30:31 -0400 Subject: [PATCH] fix a regexp parsing bug due to a stray `break` --- internal/js_parser/js_parser.go | 1 - internal/js_parser/js_parser_test.go | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/js_parser/js_parser.go b/internal/js_parser/js_parser.go index ea9541e77d4..3a157587238 100644 --- a/internal/js_parser/js_parser.go +++ b/internal/js_parser/js_parser.go @@ -11571,7 +11571,6 @@ pattern: case '\\': i++ // Skip the escaped character } - break } case '(': diff --git a/internal/js_parser/js_parser_test.go b/internal/js_parser/js_parser_test.go index d615b5a81b8..cd0a05011f9 100644 --- a/internal/js_parser/js_parser_test.go +++ b/internal/js_parser/js_parser_test.go @@ -577,6 +577,7 @@ func TestAwait(t *testing.T) { } func TestRegExp(t *testing.T) { + expectPrinted(t, "/x/d", "/x/d;\n") expectPrinted(t, "/x/g", "/x/g;\n") expectPrinted(t, "/x/i", "/x/i;\n") expectPrinted(t, "/x/m", "/x/m;\n") @@ -584,6 +585,9 @@ func TestRegExp(t *testing.T) { expectPrinted(t, "/x/u", "/x/u;\n") expectPrinted(t, "/x/y", "/x/y;\n") + expectParseError(t, "/)/", ": ERROR: Unexpected \")\" in regular expression\n") + expectPrinted(t, "/[\\])]/", "/[\\])]/;\n") + expectParseError(t, "/x/msuygig", `: ERROR: Duplicate flag "g" in regular expression : NOTE: The first "g" was here: