[racket] Bug matching shortest possible matches in regexp-replace*

From: Noel Welsh (noelwelsh at gmail.com)
Date: Wed Jan 12 12:15:47 EST 2011

A pattern like (.)? causes the following error:

racket@> (regexp-replace* #px"(.)?" "a" (lambda args "foo"))
car: expects argument of type <pair>; given #f

 === context ===
/usr/local/plt-head/collects/racket/private/string.rkt:174:7: loop
/usr/local/plt-head/collects/racket/private/string.rkt:314:11: core
/usr/local/plt-head/collects/racket/private/misc.rkt:78:7


Replace the insert function with a string and it works:

racket@> (regexp-replace* #px"(.)?" "a" "foo")
"foofoo"


Get rid of the ? and it works:

racket@> (regexp-replace* #px"(.)" "a" (lambda args "foo"))
"foo"


I guess this has to do with constructing the args list to apply to the
insert function.

N.


Posted on the users mailing list.