<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>172419</bug_id>
          
          <creation_ts>2017-05-20 13:30:50 -0700</creation_ts>
          <short_desc>[JSC] Introduce @nakedConstructor to builtin JS</short_desc>
          <delta_ts>2021-01-04 11:04:34 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>200898</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>172413</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yusuke Suzuki">ysuzuki</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>saam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1311057</commentid>
    <comment_count>0</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-05-20 13:30:50 -0700</bug_when>
    <thetext>I would like to introduce a new function annotation (like @globalPrivate), @nakedConstructor.
If this annotation is attached, the function becomes constructor, but it does not create_this automatically.
The function need to return an object constructed from this function. Of course, the function need to care about new.target.

This is very useful for Map, Set, and Promise constructors. These constructors do some JS specific things.
For example, Set constructor takes an iterable object as its argument. And perform iteration and add values to the constructed object.
If we can write it in JS, it is very nice...
In the case of Promise, promise will invoke executor function, (new Promise(executor)). Currently, we always invoke this function in a tricky way.
If we can implement the Promise constructor like the following, it is quite nice.

@nakedConstructor
function Promise(executor)
{
    &apos;use strict&apos;;

    var promise = @constructPromise(new.target);
    // some initialization...
    executor(promise.resolve, promise.reject);
    return promise;
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1311152</commentid>
    <comment_count>1</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-05-21 13:01:28 -0700</bug_when>
    <thetext>Sounds like a good idea to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1717170</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2021-01-04 11:04:34 -0800</bug_when>
    <thetext>(In reply to Yusuke Suzuki from comment #0)
&gt; I would like to introduce a new function annotation (like @globalPrivate), @nakedConstructor.
&gt; If this annotation is attached, the function becomes constructor, but it
&gt; does not create_this automatically.

@nakedConstructor annotation was introduced in r249509.

*** This bug has been marked as a duplicate of bug 200898 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>