-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Right now when regexes fail to parse, we throw an ArgumentException with a string. However internally we have more information -- the offset into the pattern and in many cases the type of failure eg RegexParseError.ReversedCharRange
. These are included in most or all cases in the exception, but only when cast to RegexParseException which is an internal type.
As noted here dotnet/corefx#29178 (comment) and #372 (comment) tooling could potentially use this data eg to squiggle the location in a regex.
(Not apparently @CyrusNajmabadi's Roslyn parser by that's used by VS -- although it obtains the offset by essentially reimplementing the parser, it apparently has other reasons it had to do this.)
If we did this we would have to be comfortable with sometimes changing the offset and/or error for particular invalid patterns, since this may be inevitable when changing and refactoring hte parser. We would not want to consider that a breaking change.
I have no opinion on whether this is worthwhile, just logging to record it.