Skip to content

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

@JakeYallop

Description

@JakeYallop

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("");

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions