diff --git a/src/array.js b/src/array.js index 0f1e969f98..8afd1a86c4 100644 --- a/src/array.js +++ b/src/array.js @@ -121,6 +121,7 @@ function Join(array, length, separator, convert) { if (IS_STRING(e)) return e; return convert(e); } + return ''; } // Construct an array for the elements. @@ -160,7 +161,7 @@ function Join(array, length, separator, convert) { function ConvertToString(x) { - if (IS_STRING(x)) return x; + // Assumes x is a non-string. if (IS_NUMBER(x)) return %_NumberToString(x); if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x)); diff --git a/src/v8natives.js b/src/v8natives.js index 6efb1429e6..b4cb7cd3da 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -1183,7 +1183,7 @@ function NewFunction(arg1) { // length == 1 if (n > 1) { p = new $Array(n - 1); for (var i = 0; i < n - 1; i++) p[i] = %_Arguments(i); - p = Join(p, n - 1, ',', ToString); + p = Join(p, n - 1, ',', NonStringToString); // If the formal parameters string include ) - an illegal // character - it may make the combined function expression // compile. We avoid this problem by checking for this early on.