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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Aug 13 07:20:55 PDT 2009


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





--- Comment #20 from Raphael Speyer <rspeyer at gmail.com>  2009-08-13 07:20:53 PDT ---
(In reply to comment #19)
> (In reply to comment #18)
> > (In reply to comment #17)
> [...]
> > 
> > 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.
> 
> Yes, at the "language level" `RegExp` objects don't have [[Call]], but don't
> forget that ES3 allows implementations to extend language and still be
> considered conforming. Quoting section 2:
> 
> | A conforming implementation of ECMAScript is permitted to provide 
> | additional types, values, objects, properties, and functions beyond those
> | described in this specification. In particular, a conforming implementation
> | of ECMAScript is permitted to provide properties not described in this
> | specification, and values for those properties, for objects that are
> | described in this specification.
> 
> So here we are with a conforming implementation that adds [[Call]] to RegExp
> objects. Note that nowhere does ES3 explicitly disallow for `RegExp` objects to
> have [[Call]] as it does for, say, `Math` or "Global object".

Good points. I guess to some extent it's a matter of interpretation here.

To me /a/('abc') just looks like syntactic sugar for /a/.exec('abc'). /a/ is
certainly not a member of the "function" objects described in section 13 or
15.3 of the spec. The view that it's simply (unspecified) syntactic sugar, and
doesn't change anything about the runtime behaviour seems to be Mozilla's
approach.

On the other hand, WebKit seem to have taken it as both additional syntax and
also a semantic change such that while a RegExp instance is not a function as
in "/a/ instanceof Function", it does have an internal [[Call]] property, which
is called by this new syntax. Perhaps that view is just as valid, but it does
alter the behaviour of syntactically identical programs. It's hard to tell
who's right because this behaviour was never specified to begin with.

I guess there's not much more for me I can say here. This sort of thing is best
clarified, and specified (or explicitly not specified) by the TC39 commitee.

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