If pattern is not a regexp, it should be converted toString before the replacement value has it's toString conversion called.
Created attachment 111353 [details] Fix
Fixed in r97680