Skip to content

Anchored search with reverse suffix strategy does not work #1036

Closed
@vthib

Description

@vthib

What version of regex are you using?

regex-automata 0.3.2

Describe the bug at a high level.

Some regexes do not seem to uphold the anchored constraint on the provided input.
AFAICT, this seems related to the reverse suffix strategy.

What are the steps to reproduce the behavior?

$ regex-cli find match meta --anchored -p '.c' -y 'abc'
     parse time:  11.8µs
 translate time:  9.2µs
build meta time:  677.2µs
    search time:  55.8µs
  total matches:  1
0:1:3:bc

Minimal reproducer of how I stumbled upon this bug:

use regex_automata::{meta, Anchored, Input};

fn main() {
    let regex = meta::Regex::new(".c").unwrap();
    let res = regex.find(Input::new("abc").anchored(Anchored::Yes));

    println!("expected None, got: {:?}", res);
}

What is the actual behavior?

A match can be found with the start offset not matching the anchored position, indicating the search was not anchored.

What is the expected behavior?

In the reproducers just above, no matches should be returned.

Activating the logs seem to indicate the reverse suffix strategy is used. I suppose it does not handle the anchored parameter properly.

As a side-note, thank you for this amazing release! I've been eagerly awaiting it since the first time you teased it, as the API exposed notably in regex-automata will help me tremendously on some of my projects. I've just started playing a bit with the new API and migrating to this new anchored parameter, and stumbled upon this bug on one of my test-case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions