Skip to content

Conversation

@pandaman64
Copy link

Previously, the HIR translation of ClassUnicode ignored the != operator in the ClassUnicodeKind::NamedValue variant as it referred to ClassUnicode::negated, which describes whether the class uses \p or \P.

This commit fixes the issue by calling ClassUnicode::is_negated.

Bug reproducer

Playground

use regex_syntax;

fn ast_parse(pattern: &str) -> regex_syntax::ast::Ast {
    let mut parser = regex_syntax::ast::parse::Parser::new();
    parser.parse(pattern).unwrap()
}

fn main() {
    // AST parser correctly parses the != operator
    println!("{:#?}", ast_parse("\\p{gc=separator}"));
    println!("{:#?}", ast_parse("\\p{gc!=separator}"));
    
    // The HIR translation forgets !=
    let hir1 = regex_syntax::parse("\\p{gc=separator}");
    let hir2 = regex_syntax::parse("\\p{gc!=separator}");
    println!("hir1 == hir2: {}", hir1 == hir2);
    println!("{:#?}", hir1);
    println!("{:#?}", hir2);
}
  • Expected behavior: hir1 == hir2 should be false.
  • Actual behavior: hir1 == hir2 is true.

Previously, the HIR translation of ClassUnicode ignored the != operator in the ClassUnicodeKind::NamedValue variant as it referred to ClassUnicode::negated, which describes whether the class uses \p or \P.

This commit fixes the issue by calling ClassUnicode::is_negated.
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.

1 participant