Skip to content

Handle flag-u character classes when Unicode sets are disabled - #39

Open
tanveerchana wants to merge 1 commit into
slevithan:mainfrom
tanveerchana:fix-null-unicode-sets
Open

tanveerchana wants to merge 1 commit into
slevithan:mainfrom
tanveerchana:fix-null-unicode-sets

Conversation

@tanveerchana

Copy link
Copy Markdown

With disable.v: true and unicodeSetsPlugin: null, rewrite("(?>[[])", options) leaves the atomic group unreplaced and produces a pattern that throws Invalid group under flag u. Parsers assume every unescaped [ starts a nested class, although it is a literal inside a flag-u class.

Normalize literal class openers to \[ before extended-syntax parsing. Carry class context across raw template fragments and interpolated patterns, skip flag-x comments, and pass Unicode-set mode to plugins. Direct atomic, possessive and subroutine plugin calls also honor flag u.

Fixes #30.

Validation on Linux / Node.js 24.22.1:

  • The issue regression failed on the original implementation with Invalid group; interpolation checks also exposed a missing context case before the final fix.
  • npm exec --yes pnpm@10.30.3 -- test: 238 specs, 0 failures; TypeScript tests and ATTW package checks passed. Includes builds and declaration generation.
  • Additional internal-plugin and syntax-mode controls passed; git diff --check passed.
  • CI’s Node 18/20/23 matrix was not run locally.

Normalize literal class openers before extended-syntax parsing and preserve character-class context across template fragments. Support flags in direct internal plugin calls. Add issue slevithan#30 regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edge case when unicodeSetsPlugin is explicitly null

1 participant