[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

Replace the insert function with a string and it works:

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

Get rid of the ? and it works:

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

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


Posted on the users mailing list.