Skip to content

Invalid regex generated with 'useUnicodeFlag:true' for regexes with - #16

@loganfsmyth

Description

@loganfsmyth

Reported in babel/babel#7891

Reproduction:

const pattern = '-';
const processedPattern = rewritePattern(pattern, 'u', { useUnicodeFlag: true });

// throws
new RegExp(processedPattern, 'u');

Looks to be an issue because IdentityEscape is essentially redefined when U is enabled. https://www.ecma-international.org/ecma-262/8.0/#prod-IdentityEscape

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions