Skip to content

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

Open
@sixears

Description

@sixears

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions