fholm / IronJS

IronJS - A JavaScript implementation for .NET
http://ironjs.wordpress.com
Apache License 2.0
680 stars 79 forks source link

String.replace is tracking "lastIndex" on non-global regexps? #32

Closed otac0n closed 13 years ago

otac0n commented 13 years ago

This is blocking the V8 test regexp.js.

Here is the minimum repro case:

var re89 = /\s+$/;
'Oyvpxchaxg\x0a'.replace(re89, '');
'Svanamra\x0a'.replace(re89, '');

It doesn't appear that the if not search.Global and search.Put stuff is correct for String.prototype.replace.

Native.String.fs lines 213-247

otac0n commented 13 years ago

I'll take a look at this as soon as I can, but it may be a couple of days. The spec says "Do the search in the same manner as in String.prototype.match, including the update of searchValue.lastIndex.", but as far as I'm aware, lastIndex is only updated for global regexps.

fholm commented 13 years ago

Fixed in 63adef9ebaa354c