Reviewers: Søren Gjesse,
Description:
Change recursive error printing to just replace recursively
encountered error objects with the empty string. This actually does
match the Safari behaviour.
Please review this at http://codereview.chromium.org/6259010/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/messages.js
M test/mjsunit/cyclic-error-to-string.js
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index
d65425525dd0c16e3f3ebf4352a14ff4dfd4e7ea..4a89647577b05b205b62ebc30f65d365d271f1c2
100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -1033,19 +1033,16 @@ function errorToStringDetectCycle() {
}
function errorToString() {
- // These helper functions are needed because access to properties on
+ // This helper function is needed because access to properties on
// the builtins object do not work inside of a catch clause.
function isCyclicErrorMarker(o) { return o === cyclic_error_marker; }
- function isVisitedErrorsEmpty() { return visited_errors.length === 0; }
try {
return %_CallFunction(this, errorToStringDetectCycle);
} catch(e) {
- // Propagate cyclic_error_marker exception until all error
- // formatting is finished and then return the empty string. Safari
- // and Firefox also returns the empty string when converting a
- // cyclic error to a string.
- if (isCyclicErrorMarker(e) && isVisitedErrorsEmpty()) return '';
+ // If this error message was encountered already return the empty
+ // string for it instead of recursively formatting it.
+ if (isCyclicErrorMarker(e)) return '';
else throw e;
}
}
Index: test/mjsunit/cyclic-error-to-string.js
diff --git a/test/mjsunit/cyclic-error-to-string.js
b/test/mjsunit/cyclic-error-to-string.js
index
7c43fc580e8378f00cfe22ba80f3948c726f8b21..2502b5340fd87ca4601160027f4435c6f443b452
100644
--- a/test/mjsunit/cyclic-error-to-string.js
+++ b/test/mjsunit/cyclic-error-to-string.js
@@ -36,11 +36,11 @@ e.name = e;
e.message = e;
e.stack = e;
e.arguments = e;
-assertEquals('', e + '');
+assertEquals(': ', e + '');
e = new Error();
e.name = [ e ];
e.message = [ e ];
e.stack = [ e ];
e.arguments = [ e ];
-assertEquals('', e + '');
+assertEquals(': ', e + '');
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev