fix ascii class bug and 'Hir::is_match_empty' bug#860
Merged
Conversation
This fixes a bug in how ASCII class unioning was implemented. Namely, it previously and erroneously unioned together two classes and then applied negation/case-folding based on the most recently added class, even if the class added previously wasn't negated. So for example, given the regex '[[:alnum:][:^ascii:]]', this would initialize the class with '[:alnum:]', then add all '[:^ascii:]' codepoints and then negate the entire thing because of the negation in '[:^ascii:]'. Negating the entire thing is clearly wrong and not the intended semantics. We fix this by applying negation/case-folding only to the class we're dealing with, and then we union it with whatever existing class we're building. Fixes #680
This was incorrectly defined for \b. Previously, I had erroneously made it return true only for \B since \B matches '' and \b does not match ''. However, \b does match the empty string. Like \B, it only matches a subset of empty strings, depending on what the surrounding context is. The important bit is that it can match *an* empty string, not that it matches *the* empty string. We were not yet using this predicate anywhere in the regex crate, so we just fix the implementation and update the tests. This does present a compatibility hazard for anyone who was using this function, but as of this time, I'm considering this a bug fix since \b clearly matches an empty string. Fixes #859
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The commit messages should explain a bit, but this picks off a couple low hanging bug fruits.
Fixes #680, Fixes #859