Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automata: fix bug where reverse NFA lacked an unanchored prefix #1170

Merged
merged 1 commit into from
Mar 4, 2024

Commits on Mar 4, 2024

  1. automata: fix bug where reverse NFA lacked an unanchored prefix

    Previously, when compiling a Thompson NFA, we were omitting an
    unanchored prefix when the HIR contained a `^` in its prefix. We did
    this because unanchored prefix in that case would never match because of
    the requirement imposed by `^`.
    
    The problem with that is it's incorrect when compiling a reverse
    automaton. For example, in the case of building a reverse NFA for `^Qu`,
    we should sitll include an unanchored prefix because the `^` in that
    case has no conflict with it. It would be like if we omitted an
    unanchored prefix for `Qu$` in a forward NFA, which is obviously wrong.
    
    The fix here is pretty simple: in the reverse case, check for `$` in the
    suffix of the HIR rather than a `^` in the prefix.
    
    Fixes #1169
    BurntSushi committed Mar 4, 2024
    Configuration menu
    Copy the full SHA
    da07b93 View commit details
    Browse the repository at this point in the history