W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2015

[Bug 22808] Throw if object is constructed without new

From: <bugzilla@jessica.w3.org>
Date: Mon, 09 Feb 2015 18:34:54 +0000
To: public-script-coord@w3.org
Message-ID: <bug-22808-3890-J3uuzCAKjf@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=22808

--- Comment #17 from Allen Wirfs-Brock <allen@wirfs-brock.com> ---
(In reply to Boris Zbarsky from comment #16)

The problem is that many of the ECMAScript library constructors, which are
allspecified to be "Built-In Function objects", do support being "called as a
function". So if we added [[FunctionKind]] to Built-in Function I would also
have to specify it's setting for each ES built-in.  I might consider doing that
if I wasn't within about a week of having to freeze the final ES6 draft.

As an alternative approach consider treating this similarly to what you do for
parameter type checking. You can determine whether you are called by as
function rather than via [[Construct]] by checking the value of NewTarget.  It
has the value undefined if the function is being invoked via [[Call]]. 

So, in your WebIDL parameter checking also check NewTarget (for constructors).

This is essentially what the ES6 spec. does,  individually for each built-in
constructor that is not callable.  For example see:
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-map-iterable

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Received on Monday, 9 February 2015 18:34:57 UTC

This archive was generated by hypermail 2.3.1 : Monday, 9 February 2015 18:34:57 UTC