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

Unified Diff: src/string.js

Issue 564863002: ES6: String(symbol) should work like symbol.toString (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code review feedback Created 6 years, 3 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/es6/symbols.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index ae65264d4a3ae2c29cc39add829dd45e51ccf0c3..8afd294179b4630d8d73958d6fbb1e39aa46ce6f 100644
--- a/src/string.js
+++ b/src/string.js
@@ -9,11 +9,12 @@
// -------------------------------------------------------------------
function StringConstructor(x) {
- var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x);
+ if (%_ArgumentsLength() == 0) x = '';
if (%_IsConstructCall()) {
- %_SetValueOf(this, value);
+ %_SetValueOf(this, TO_STRING_INLINE(x));
} else {
- return value;
+ return IS_SYMBOL(x) ?
+ %_CallFunction(x, SymbolToString) : TO_STRING_INLINE(x);
}
}
« no previous file with comments | « no previous file | test/mjsunit/es6/symbols.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698