archives

« Bugzilla Issues Index

#21 — String.prototype.match should not require built-in exec method


String.prototype.match (15.5.4.10) in ES5 is specified as calling the "standard built-in" RegExp.prototype.exec method. In ES3 the "standard built-in" qualification was not present. In general, for ES5 we tried to be explicit about when we expected to call the actual built-in method as opposed to whatever the actual current value of the property happens to be. However, in some cases, such as this we may have unnecessarily over specified the requirement.

For example,the current specification precludes someone from extending RegExpo semantics and replacing the exec method with a new one that works by dispatching to either the built-in exec or extension code for the new semantics. The match spec. requires actual [[Call]]'s of the exec and the algorithm doesn't really have any obvious dependency upon using the built-in method and not an ECMAScript code method.

Instead of specifying use of the standard built-in method it should just do a [[Get]] to access the objects exec method.


In fact there are some dependencies upon using the built-in exec method. The way the algorithm is coded assumes that after a call to exec, that the lastIndex property of the regexp object will have a Number value. It doesn't do any coercion to ensure this. This assumption is valid for the built-in exec but might not be correct for an alternative exec method.

To correctly generalize the match method, the appropriate coercions would need to be added to the algorith.


fixed in rev 14 editor's draft


in Rev 14 draft