[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:56:18 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=28117
--- Comment #18 from Raphael Speyer <rspeyer at gmail.com> 2009-08-13 00:56:17 PDT ---
(In reply to comment #17)
>
> json2.js uses typeof holder === "function" to determine whether an object
> IsCallable,
That seems reasonable to me.
> and regexp instances have the type "function".
I think this is the crux of the issue. I know that webkit gives typeof /a/ ===
'function', but I don't understand why. The spec does not say anywhere that a
RegExp defines the internal property [[Call]].
> 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"
>
Exactly. So, wouldn't RegExp's fall into the first category? Yes, they can be
treated as functions, but that's a particular vendor extension, it's not how
RegExp instances are specified to behave.
> IsCallable is defined in section 9.11:
> If the argument object has an [[Call]] internal method, then return true,
> otherwise
> return false.
Right, and again, as per the spec, a RegExp does not have a [[Call]] internal
method.
>
> In other words, a RegExp instance has [[Call]] so typeof should be "function",
> and [[IsCallable]] is true.
>
I think we forked back at /a/('a') implying that at a specification level,
[[Call]] is defined for RegExp's.
> 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).
>
Granted, it's not going to be typical, and I can't actually think of a very
good use case for it myself. However enumerable properties can be defined on
RegExp's or their prototype, as can the toJSON method. I think this is more
about conformance with the spec.
> 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.
Well, as I said above, as far as I can tell, the spec says that RegExp is not
callable, in the sense that the internal [[Call]] property is not defined,
IsCallable will return false and thus at the language level, typeof should
return 'object', and stringify should not ignore it.
--
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