Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1458)

Unified Diff: src/js/array.js

Issue 1747933002: Fix spec-compliance bug in Array.prototype.join. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/array-join.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/array.js
diff --git a/src/js/array.js b/src/js/array.js
index 27109eabf9f013237bdf3fb12b89e02714f18bbb..1468d57c6cae52f3f4c307609d1c58a9517382f5 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -214,15 +214,19 @@ function Join(array, length, separator, convert) {
// Non-empty separator case.
// If the first element is a number then use the heuristic that the
// remaining elements are also likely to be numbers.
- if (!IS_NUMBER(array[0])) {
- for (var i = 0; i < length; i++) {
- var e = array[i];
+ var e = array[0];
+ if (!IS_NUMBER(e)) {
+ if (!IS_STRING(e)) e = convert(e);
+ elements[0] = e;
+ for (var i = 1; i < length; i++) {
+ e = array[i];
if (!IS_STRING(e)) e = convert(e);
elements[i] = e;
}
} else {
- for (var i = 0; i < length; i++) {
- var e = array[i];
+ elements[0] = %_NumberToString(e);
+ for (var i = 1; i < length; i++) {
+ e = array[i];
if (IS_NUMBER(e)) {
e = %_NumberToString(e);
} else if (!IS_STRING(e)) {
« no previous file with comments | « no previous file | test/mjsunit/array-join.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698