Summary

irregex extracts wrong submatches in some situations

Metadata

Description

This works:

 (irregex-fold
  (irregex
   '(seq (* nonl)
         (or "kbd" (=> eventnum1 (seq "event" (+ num)))) (* nonl)
         (or "kbd" (=> eventnum2 (seq "event" (+ num)))) (* nonl)
         ;;eol
         
         )
   'backtrack
   )
  (lambda (i m s)
    (cons (or (irregex-match-substring m 'eventnum1 )
              (irregex-match-substring m 'eventnum2 ))
          s))
  '()
  "kbd event11\nkbd event10\nkbd event9")

But if you remove 'backtrack it misses the last "1" digit.

Changes and comments

[2013-08-25 01:42:46 UTC] sjamaan wrote:

First attempt at simplification:

 #!scm
 (irregex-match-substring
  (irregex-match (irregex
                  '(seq (* nonl) (or "x" ($ "a")) "a"))
                 "xa")
  1)
 => "a" ;; Should return #f, since the first submatch doesn't match "x"

[2013-08-25 08:45:07 UTC] sjamaan wrote:

It gets weirder: Upstream irregex behaves correctly on this!

[2013-08-25 09:02:47 UTC] sjamaan changed status from new to closed

[2013-08-25 09:02:47 UTC] sjamaan set resolution to fixed

[2013-08-25 09:02:47 UTC] sjamaan wrote:

OK, I just verified and it looks like Irregex 0.8.3 contains the bug, later ones do not.

I had no idea about the state of Chicken 4.8.0 (that's why I didn't bother testing this with master), but after digging through the git log and the mailinglist archives it turned out that chicken 4.8.0 contains a copy of Irregex 0.8.3; the latest release is 0.9.2, which has some major performance enhancements.

The good part is, CHICKEN master contains this version, and I'm happy to report it just works there. So that means this ticket can be closed. Woohoo ;)

I guess we really need to gear up for a release Real Soon Now!