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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Aug 13 11:13:15 PDT 2009


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





--- Comment #23 from Oliver Hunt <oliver at apple.com>  2009-08-13 11:13:13 PDT ---
> > 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.
And you can take that up with mozilla who decided to give RegExp are

If an object can be called it is by definition callable.  To be called an
object must provide [[Call]] -- if you look at section 11.2.3 you will see that
a function call will throw an exception if IsCallable(func) returns false. 
Therefore by definition IsCallable must be true.

> 
> > 
> > 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.
Mozilla extended the spec by saying RegExps were callable, thus forcing us to
implement this extension or be broken.  [[Call]] is defined on on RegExp as an
extension, but that does not make it not present.

> 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.
[[Call]] is defined, IsCallable is true, typeof is function, and serialisation
should skip it.  If you want to argue this more, please provide a logical
explanation beyond "firefox violates spec here, so should you"

Once again, the fact that /a/("a") does not throw an exception demonstrates
that IsCallable(/a/) must be true in firefox

-- 
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