archives

« Bugzilla Issues Index

#4425 — 21.1.3.18 Typo: "searchStr" vs "searchString"


Step 8 of String.prototype.startsWith incorrectly references the user-defined "searchString" variable (which can never be an abrupt completion) instead of the internally-defined "searchStr" variable (which may be an abrupt completion in cases where the ToString operation fails):

> 7. Let searchStr be ToString(searchString).
> 8. ReturnIfAbrupt(searchString).

Although a literal interpretation could result in incorrect behavior, that would depend on very liberal implementation of the steps that follow, specifically:

> 13. Let searchLength be the number of elements in searchStr.
> [...]
> 15. If the sequence of elements of S starting at start of length searchLength is the same as the full element sequence of searchStr, return true.

I'm filing this as a editorial issue because I think the intent is clear.


Fixed in ES2016 Draft.