Status: New
Owner: ----

New issue 2519 by [email protected]: Inconsistent treatment of toString leads to poor error messages
http://code.google.com/p/v8/issues/detail?id=2519

In V8 version 3.13.7.6, I get these nice error messages:

"Object #<Foo> has no method 'foo'"

when I evaluate: function Foo() {}; (new Foo).foo()

"Object Foo has no method 'foo'"

when I evaluate: function Foo() {}; Foo.prototype.toString = function() { return 'Foo'}; (new Foo).foo()

In V8 version 3.16.4.1, it quickly degenerates into "[object Object]" which really conveys no information:

"Object #<Foo> has no method 'foo'"

when I evaluate: function Foo() {}; (new Foo).foo()

But:

"Object [object Object] has no method 'foo'"

when I evaluate: function Foo() {}; Foo.prototype.toString = function() { return 'Foo'}; (new Foo).foo()

One can argue whether or not it is a good idea to invoke a user-defined toString when formatting error messages, but I think "#<Foo>" is much to be preferred over "[object Object]".


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to