KEMBAR78
`<regex>`: Remove `error_syntax` by muellerj2 · Pull Request #5542 · microsoft/STL · GitHub
Skip to content

Conversation

@muellerj2
Copy link
Contributor

Resolves #438. There were two remaining uses of error_syntax:

  • One is in the region parsing non-capturing groups and assertions. If it is not one of these, then ? is essentially a quantifier applied to nothing, so error_badrepeat seems an apt choice among the available codes to me. (The error code error_paren used by libstdc++ feels a bit weird to me in this context because this error code is intended for unbalanced parentheses, which this isn't.)
  • The other case can only be reached by an STL or compiler bug, so I replaced it by _STL_INTERNAL_CHECK: _Alternative() only returns normally when _Mchar is _Meta_eos, _Meta_bar or it is _Meta_rpar while _Disj_count != 0. Its caller, _Disjunction(), only returns if _Mchar is not _Meta_bar after _Alternative() returned. So this means the error could only be thrown when _Mchar is _Meta_eos or _Meta_rpar with _Disj_count != 0. But in either case, this is a bug in the parser: Either _Meta_eos was assigned to _Mchar before the end of the regex was reached (but see _Trans() for the only case where _Meta_eos is assigned) or an unbalanced number of increments and decrements to Disj_count were performed.

@muellerj2 muellerj2 requested a review from a team as a code owner May 24, 2025 18:23
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews May 24, 2025
@StephanTLavavej StephanTLavavej self-assigned this May 27, 2025
@StephanTLavavej StephanTLavavej added bug Something isn't working regex meow is a substring of homeowner labels May 27, 2025
Comment on lines 575 to 578
case regex_constants::_Error_parse: // TRANSITION, keeping behavior
return "regex_error(error_parse)";
case regex_constants::error_syntax:
case regex_constants::_Error_syntax:
return "regex_error(error_syntax)";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested: It would be more consistent to follow the pattern of commenting // TRANSITION, keeping behavior here, but the comment on the enumerator definition is sufficient. This isn't worth resetting testing.

@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews May 27, 2025
@StephanTLavavej StephanTLavavej removed their assignment May 27, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews May 28, 2025
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 97a3b13 into microsoft:main May 28, 2025
48 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews May 28, 2025
@StephanTLavavej
Copy link
Member

😻 ❌ 🎉

@muellerj2 muellerj2 deleted the regex-remove-error-syntax branch May 31, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working regex meow is a substring of homeowner

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

<regex>: std::regex uses a nonstandard regex constant "error_syntax"

2 participants