Bug 16498 - ''.constructor.toString() gives [function]
Summary: ''.constructor.toString() gives [function]
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Darin Adler
URL: http://crschmidt.net/projects/webkit/...
Keywords: HasReduction
Depends on:
Reported: 2007-12-17 20:53 PST by Christopher Schmidt
Modified: 2008-01-27 00:57 PST (History)
0 users

See Also:

patch (23.75 KB, patch)
2008-01-26 10:02 PST, Darin Adler
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Schmidt 2007-12-17 20:53:10 PST
''.constructor.toString() gives back "[function]" in Safari. In FF and Opera (and I believe IE) this returns:

>>> ''.constructor.toString()
function String() { [native code] }

or something similar.

(Test.AnotherWay uses this as a way to determine what type of object something is for some reason I'm not sure I understand, which is how I bumped into it.)
Comment 1 David Kilzer (:ddkilzer) 2007-12-18 05:49:57 PST
Confirmed difference to Firefox and Opera with a local debug build of WebKit r28774 with Safari 3.0.4 (523.12) on Mac OS X 10.4.11 (8S165).

Is the format of the returned string for native functions covered by any spec?

Comment 2 Eric Seidel (no email) 2008-01-01 12:32:30 PST
If this is still an issue, it's easy enough to fix.  We just need a good test case (w/o an alert, DRT compatible).  Ideally one which uses the standard fast/js/ style of just being a .js file and using shouldBe, etc.
Comment 3 Darin Adler 2008-01-26 08:48:22 PST
functionProtoFuncToString already has a case that dumps in this format, with "native code" in the string. We just need to trigger it at the right time.
Comment 4 Darin Adler 2008-01-26 10:02:30 PST
Created attachment 18709 [details]
Comment 5 Darin Adler 2008-01-27 00:57:54 PST
Committed revision 29817.