<?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>153909</bug_id>
          
          <creation_ts>2016-02-04 21:10:08 -0800</creation_ts>
          <short_desc>Bound functions toString method should return &quot;bound &quot; + the target function&apos;s toString()</short_desc>
          <delta_ts>2022-07-15 17:32:53 -0700</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>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nikita Vasilyev">nvasilyev</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>burg</cc>
    
    <cc>cdumez</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>gskachkov</cc>
    
    <cc>joepeck</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>nvasilyev</cc>
    
    <cc>oliver</cc>
    
    <cc>saam</cc>
    
    <cc>sukolsak</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1162306</commentid>
    <comment_count>0</comment_count>
    <who name="Nikita Vasilyev">nvasilyev</who>
    <bug_when>2016-02-04 21:10:08 -0800</bug_when>
    <thetext>Via Bug 153796 [ES6] bound functions .name property should be &quot;bound &quot; + the target function&apos;s name

We improved bound functions .name, but .toString() wasn&apos;t affected.

&gt; function foo() {return 42}
&gt; boundFunc = foo.bind(null)
&gt; boundFunc.name
&lt; &quot;bound foo&quot;
&gt; boundFunc.toString()
&lt; &quot;function foo() {
      [native code]
  }&quot;


What if we return the following instead:

&gt; boundFunc.toString()
&lt; &quot;function bound foo() {return 42}&quot;

or this:

&gt; boundFunc.toString()
&lt; &quot;bound function foo() {return 42}&quot;

I have no preference.

Two things are different from the current behavior:

1. Instead of &quot;[native code]&quot;, the original content of the function is shown.
   This is much more convenient for debugging. Currently, all anonymous
   functions look alike:

   function () {
       [native code]
   }

2. Added &quot;bound&quot; prefix.


This is just an idea; I don&apos;t think ES6 spec touches this point.

What do you think?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162495</commentid>
    <comment_count>1</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-02-05 14:11:37 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; Via Bug 153796 [ES6] bound functions .name property should be &quot;bound &quot; + the
&gt; target function&apos;s name
&gt; 
&gt; We improved bound functions .name, but .toString() wasn&apos;t affected.
&gt; 
&gt; &gt; function foo() {return 42}
&gt; &gt; boundFunc = foo.bind(null)
&gt; &gt; boundFunc.name
&gt; &lt; &quot;bound foo&quot;
&gt; &gt; boundFunc.toString()
&gt; &lt; &quot;function foo() {
&gt;       [native code]
&gt;   }&quot;
&gt; 
&gt; 
&gt; What if we return the following instead:
&gt; 
&gt; &gt; boundFunc.toString()
&gt; &lt; &quot;function bound foo() {return 42}&quot;
&gt; 
&gt; or this:
&gt; 
&gt; &gt; boundFunc.toString()
&gt; &lt; &quot;bound function foo() {return 42}&quot;
&gt; 
&gt; I have no preference.
&gt; 
&gt; Two things are different from the current behavior:
&gt; 
&gt; 1. Instead of &quot;[native code]&quot;, the original content of the function is shown.
&gt;    This is much more convenient for debugging. Currently, all anonymous
&gt;    functions look alike:
&gt; 
&gt;    function () {
&gt;        [native code]
&gt;    }
Depending on how we do this, it&apos;s not spec compliant.
toString() needs to return a string that if eval()ed
in the original context, would reproduce an identical
function. Or, if that&apos;s not possible, the toString(),
when eval()ed, must throw a syntax error.
We could achieve a syntax error with your proposal of:
&quot;function bound foo { return 42; }&quot;
And I considered doing this.
But, there is new a new proposal that would require
the use of &quot;[native code]&quot; here:
https://raw.githubusercontent.com/michaelficarra/Function-prototype-toString-revision/fc69a0a31dc6d625736bfbb712ac782eb241ff3d/proposal.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162496</commentid>
    <comment_count>2</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-02-05 14:13:51 -0800</bug_when>
    <thetext>though that proposal is a bit ambiguous.
It says that it&apos;s implementation dependent if the bound
function contains info about its target. But, it also
says that it must comply with &quot;the rules below&quot;, which
would lead me to think we must show &quot;[native code]&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>