String.prototype.search has a breaking change from ES5

Allen Wirfs-Brock allen at wirfs-brock.com
Sun Apr 19 18:45:03 UTC 2015


On Apr 18, 2015, at 12:46 PM, Yusuke SUZUKI wrote:

> Hi forks,
> 
> Seeing ES6 String.prototype.search, there's a breaking change from ES5.
> 
> When executing `"gnulluna".search(null)`,
> 
> In ES5, RegExp(null) => /null/ is generated, so the result becomes 1.
> 
> http://ecma-international.org/ecma-262/5.1/#sec-15.5.4.12
> 
> In ES6, we fall down to the 21.1.3.15 step 3 (because null is not undefined).
> And then reaching step 3.a,
> 
>   Let searcher be GetMethod(regexp, @@search).
> 
> Then TypeError is thrown by GetV's ToObject.
> 
> Is it intentional behavior?

Appears to be a bug.  Probably also for similar code for match, replace, and split.

Please file a bug ticket.

Allen


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150419/9caba528/attachment.html>


More information about the es-discuss mailing list