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

Regex with negated non-ascii ranges emits empty IndexOfAnyExcept check #103842

Closed
JakeYallop opened this issue Jun 21, 2024 · 1 comment · Fixed by #103851
Closed

Regex with negated non-ascii ranges emits empty IndexOfAnyExcept check #103842

JakeYallop opened this issue Jun 21, 2024 · 1 comment · Fixed by #103851
Assignees
Labels
area-System.Text.RegularExpressions in-pr There is an active PR which will close this issue when it is merged

Comments

@JakeYallop
Copy link
Contributor

Given the following regex with a pair of negated non-ascii ranges:

[GeneratedRegex("[^\u00C0-\u00FF\u0104-\u02D9]")]
private static partial Regex GetRegex();

Generates an empty IndexOfAnyExcept check:

 /// <summary>Finds the next index of any character that matches a character in the set [^\u00C0-\u00FF\u0104-\u02D9].</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static int IndexOfNonAsciiOrAny_1A08CECD494E7E816814F51CE8D08BA09C13C905B63D0D97331103DB9E7463AF(this ReadOnlySpan<char> span)
{
   unchecked
   {
       int i = span.IndexOfAnyExcept(Utilities.s_ascii_);
       if ((uint)i < (uint)span.Length)
       {
         // other code omitted for brevity
       }
   }
}

/// <summary>Supports searching for characters in or not in "".</summary>
internal static readonly SearchValues<char> s_ascii_ = SearchValues.Create("");
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

@stephentoub stephentoub self-assigned this Jun 22, 2024
@stephentoub stephentoub removed the untriaged New issue has not been triaged by the area owner label Jun 22, 2024
@stephentoub stephentoub added the in-pr There is an active PR which will close this issue when it is merged label Jun 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.RegularExpressions in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants