]> git.kaiwu.me - quickjs.git/commitdiff
fixed regexp skipping after template or private field (#596)
authorFabrice Bellard <fabrice@bellard.org>
Sat, 7 Nov 2026 11:45:55 +0000 (12:45 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 7 Nov 2026 11:45:55 +0000 (12:45 +0100)
quickjs.c

index d4ab4c3bfe3efebae4aab80997663387fdac459b..0600dee1f7567e21e100cce7d79b78a43e07a806 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -25403,9 +25403,11 @@ static BOOL is_regexp_allowed(int tok)
     case TOK_FALSE:
     case TOK_TRUE:
     case TOK_THIS:
+    case TOK_PRIVATE_NAME:
     case ')':
     case ']':
     case '}': /* XXX: regexp may occur after */
+    case TOK_TEMPLATE: /* complete template literal; "${" is handled by the caller */
     case TOK_IDENT:
         return FALSE;
     default:
@@ -25485,6 +25487,7 @@ static int js_parse_skip_parens_token(JSParseState *s, int *pbits, BOOL no_line_
                 if (level >= sizeof(state))
                     goto done;
                 state[level++] = '`';
+                last_tok = '('; /* regexp allowed after it */
             }
             break;
         case TOK_EOF: