Skip to content

Commit

Permalink
fix a regexp parsing bug due to a stray break
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed May 27, 2022
1 parent 14d9de5 commit cfb1b07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/js_parser/js_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11571,7 +11571,6 @@ pattern:
case '\\':
i++ // Skip the escaped character
}
break
}

case '(':
Expand Down
4 changes: 4 additions & 0 deletions internal/js_parser/js_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,17 @@ 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")
expectPrinted(t, "/x/s", "/x/s;\n")
expectPrinted(t, "/x/u", "/x/u;\n")
expectPrinted(t, "/x/y", "/x/y;\n")

expectParseError(t, "/)/", "<stdin>: ERROR: Unexpected \")\" in regular expression\n")
expectPrinted(t, "/[\\])]/", "/[\\])]/;\n")

expectParseError(t, "/x/msuygig",
`<stdin>: ERROR: Duplicate flag "g" in regular expression
<stdin>: NOTE: The first "g" was here:
Expand Down

0 comments on commit cfb1b07

Please sign in to comment.