[Webkit-unassigned] [Bug 28117] Native JSON.stringify does not omit functions

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Aug 13 00:19:21 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=28117





--- Comment #17 from Oliver Hunt <oliver at apple.com>  2009-08-13 00:19:20 PDT ---
(In reply to comment #16)
> (In reply to comment #15)
> 
> > As Luke mentioned above, according to the spec, a IsCallable is false for
> > RegExp's, and thus they should be serialised by JSON.stringify, in 15.12.3 step
> > 10.
> 
> That is, step 10 of the Str operation.

json2.js uses typeof holder === "function" to determine whether an object
IsCallable, and regexp instances have the type "function".  This is correct
behaviour, per ES5 (from ES262, v5, 11.4.3)
Object (native and doesn‘t implement  [[Call]])  -> "object" 
Object (native or host and implements  [[Call]]) -> "function" 

IsCallable is defined in section 9.11:
If the argument object has an [[Call]] internal method, then return true,
otherwise 
return false. 

In other words, a RegExp instance has [[Call]] so typeof should be "function",
and [[IsCallable]] is true.

You seem to believe that there is value in serialising a regexp object, when
there is not -- a serialised regexp object is either undefined (in conforming
implementations in which regexps are callable) or as the empty object {} (in
conforming implementations in whichs regexps are not callable).

Firefox is not conforming in this regard.  Arguing will not accopmlish anything
as it is pointless to add a slow check which will break behaviour relative to
json2, just to handle the specific case of RegExps, when there are numerous
other disagreements between different runtimes as to which objects are callable
(NodeLists anyone?), especially given the serialisation of RegExps is unhelpful
in either case.

If you feel really strongly about this, i suggest you go to
http://bugs.mozilla.org and file a bug on the spidermonkey RegExp object
incorrectly reporting typeof as "object" and claiming not to be callable.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list