Skip to content

Commit

Permalink
fix(parser): restore regex flag parsing (oxc-project#2007)
Browse files Browse the repository at this point in the history
As discussed in
oxc-project#1999 (comment),
this PR restores some of regex parsing behavior to as it was prior to
oxc-project#1926.
  • Loading branch information
overlookmotel authored and IWANABETHATGUY committed May 29, 2024
1 parent d41e3d8 commit aaad046
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/oxc_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit aaad046

Please sign in to comment.