sjshuck / hs-pcre2

Complete Haskell binding to PCRE2
Apache License 2.0
12 stars 2 forks source link

Access optional captures via names #4

Closed amesgen closed 3 years ago

amesgen commented 3 years ago

I think that the following should not happen:

 Λ "a" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @"a"
Just "a"
 Λ "a" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @"b"
Just*** Exception: src/hs/Text/Regex/Pcre2/Internal.hs:1275:9-70: Non-exhaustive patterns in (ls, c : rs)
 Λ "b" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @"a"
Just ""
 Λ "b" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @"b"
Just*** Exception: src/hs/Text/Regex/Pcre2/Internal.hs:1275:9-70: Non-exhaustive patterns in (ls, c : rs)

With indices, everything works fine:

 Λ "a" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @1
Just "a"
 Λ "a" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @2
Just ""
 Λ "b" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @1
Just ""
 Λ "b" ^? [_regex|(?<a>a)|(?<b>b)|] . _capture @2
Just "b"
sjshuck commented 3 years ago

Oof, thanks.