fix(parser): restore regex flag parsing (#2007)

As discussed in
https://github.com/oxc-project/oxc/pull/1999#issuecomment-1888916383,
this PR restores some of regex parsing behavior to as it was prior to
#1926.
This commit is contained in:
overlookmotel 2024-01-12 19:19:33 +00:00 committed by GitHub
parent 1ecdeaa662
commit 712e99cf9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -872,17 +872,17 @@ impl<'a> Lexer<'a> {
self.current.chars.next();
if !ch.is_ascii_lowercase() {
self.error(diagnostics::RegExpFlag(ch, self.current_offset()));
break;
continue;
}
let flag = if let Ok(flag) = RegExpFlags::try_from(ch) {
flag
} else {
self.error(diagnostics::RegExpFlag(ch, self.current_offset()));
break;
continue;
};
if flags.contains(flag) {
self.error(diagnostics::RegExpFlagTwice(ch, self.current_offset()));
break;
continue;
}
flags |= flag;
}