@@ -591,18 +591,20 @@ impl Parser {
591
591
}
592
592
class = self . class_transform ( negated, class) . canonicalize ( ) ;
593
593
if class. is_empty ( ) {
594
+ // e.g., [^\d\D]
594
595
return Err ( self . err ( ErrorKind :: EmptyClass ) ) ;
595
596
}
596
597
Ok ( Build :: Expr ( if self . flags . unicode {
597
598
Expr :: Class ( class)
598
599
} else {
599
600
let byte_class = class. to_byte_class ( ) ;
600
601
601
- // If `class` was only non-empty due to multibyte characters, the
602
+ // If `class` was only non-empty due to multibyte characters, the
602
603
// corresponding byte class will now be empty.
603
604
//
604
605
// See https://github.com/rust-lang-nursery/regex/issues/303
605
606
if byte_class. is_empty ( ) {
607
+ // e.g., (?-u)[^\x00-\xFF]
606
608
return Err ( self . err ( ErrorKind :: EmptyClass ) ) ;
607
609
}
608
610
@@ -2757,6 +2759,9 @@ mod tests {
2757
2759
test_err ! ( "[]" , 2 , ErrorKind :: UnexpectedClassEof ) ;
2758
2760
test_err ! ( "[^]" , 3 , ErrorKind :: UnexpectedClassEof ) ;
2759
2761
test_err ! ( r"[^\d\D]" , 7 , ErrorKind :: EmptyClass ) ;
2762
+
2763
+ let flags = Flags { allow_bytes : true , .. Flags :: default ( ) } ;
2764
+ test_err ! ( r"(?-u)[^\x00-\xFF]" , 17 , ErrorKind :: EmptyClass , flags) ;
2760
2765
}
2761
2766
2762
2767
#[ test]
0 commit comments