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

Non-matching captures in alternatives cause a UTF-8 Error. #183

Open
sixears opened this issue Oct 30, 2021 · 0 comments
Open

Non-matching captures in alternatives cause a UTF-8 Error. #183

sixears opened this issue Oct 30, 2021 · 0 comments
Labels

Comments

@sixears
Copy link

sixears commented Oct 30, 2021

If the regex contains a capture that isn't matched because it's in on a side of an alternation that is not used, a UTF-8 error is caused:

λ> "acd" ?=~ [re|a((b)|(c))d|]
Match {matchSource = "acd", captureNames = fromList [], matchArray = array (CaptureOrdinal {getCaptureOrdinal = 0},CaptureOrdinal {getCaptureOrdinal = 3}) [(CaptureOrdinal {getCaptureOrdinal = 0},Capture {captureSource = "acd", capturedText = "acd", captureOffset = 0, captureLength = 3}),(CaptureOrdinal {getCaptureOrdinal = 1},Capture {captureSource = "acd", capturedText = "c", captureOffset = 1, captureLength = 1}),(CaptureOrdinal {getCaptureOrdinal = 2},*** Exception: utf8_correct_bs: UTF-8 decoding error
CallStack (from HasCallStack):
  error, called at ./Text/RE/ZeInternals/Types/Match.lhs:248:13 in regex-1.1.0.0-Ejn9jxFmirEFrePEa32Cpi:Text.RE.ZeInternals.Types.Match

This also causes a similar error with capturedText, matchCaptures, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants