<?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>186991</bug_id>
          
          <creation_ts>2018-06-24 23:44:42 -0700</creation_ts>
          <short_desc>Different output compared with v8 and spidermonkey</short_desc>
          <delta_ts>2020-05-07 15:40:13 -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 Local Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>184267</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=186993</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=186992</see_also>
          <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>sunlili</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>nth10sd</cc>
    
    <cc>sunlili</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1435993</commentid>
    <comment_count>0</comment_count>
    <who name="">sunlili</who>
    <bug_when>2018-06-24 23:44:42 -0700</bug_when>
    <thetext>Hello,
The following code behaves incorrectly (inconsistent with the standard and other engines).

arr0 = [ 1, 2, 3 ];                                                                                                                 
arr1 = [ 4, 5, 6 ];  
handler1 = { 
    get: function (oTarget, sKey) { 
        print(&apos;arg &apos; + &apos;1&apos; + &apos;:get &apos; + sKey.toString()); 
        if (sKey.toString() == &apos;Symbol(Symbol.isConcatSpreadable)&apos;) { 
            arr1[&apos;length&apos;] = 4294967294;
        }   
        if (sKey.toString() == &apos;length&apos;) { 
            arr1[&apos;length&apos;] = 10; 
        }   
        if (Number(sKey.toString()) != NaN) { ; } 
        return Reflect.get(oTarget, sKey); 
    },  
    has: function (oTarget, sKey) { 
        print(&apos;arg &apos; + &apos;1&apos; + &apos;:has &apos; + sKey.toString()); 
        if (Number(sKey.toString()) != NaN) { 
            return Symbol.search;
        }   
        return Reflect.has(oTarget, sKey);
     }   
}; 
var proxy1 = new Proxy(arr1, handler1); 
func = Array.prototype.concat.bind(arr0, proxy1); 
arr2 = func(); 
print(arr2);

The output is:
arg 1:get Symbol(Symbol.isConcatSpreadable)
arg 1:get Symbol(Symbol.toPrimitive)
arg 1:get toString
arg 1:get join
arg 1:get length
arg 1:get 0
arg 1:get 1
arg 1:get 2
arg 1:get 3
arg 1:get 4
arg 1:get 5
arg 1:get 6
arg 1:get 7
arg 1:get 8
arg 1:get 9
1,2,3,4,5,6,,,,,,,

However, it should be:
arg 1:get Symbol(Symbol.isConcatSpreadable)
arg 1:get length
arg 1:has 0
arg 1:get 0
arg 1:has 1
arg 1:get 1
arg 1:has 2
arg 1:get 2
arg 1:has 3
arg 1:get 3
arg 1:has 4
arg 1:get 4
arg 1:has 5
arg 1:get 5
arg 1:has 6
arg 1:get 6
arg 1:has 7
arg 1:get 7
arg 1:has 8
arg 1:get 8
arg 1:has 9
arg 1:get 9
1,2,3,4,5,6,,,,,,,

BT group
2018.6.25</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1644200</commentid>
    <comment_count>1</comment_count>
    <who name="Gary Kwong [:gkw] [:nth10sd]">nth10sd</who>
    <bug_when>2020-04-21 21:38:35 -0700</bug_when>
    <thetext>I re-ran the testcase in comment #0 with git rev eb42a8967d53ebb95bd59b6d89662ac7fdf95a8b and it seems to show the intended output. It shows the wrong output with a build from mid-2017, or rev 011c994d52cc30bdec69aebed8ec1a025966b34a.

I then ran a bisection using robobisect, and it seems to point to the following commit as a possible fix to this bug:


commit e580b9a5fa9b5013b749e72f1c10946cb14af9aa
Author: caitp
Date:   Tue May 29 16:56:29 2018 +0000

    [JSC] Fix Array.prototype.concat fast case when single argument is Proxy
    https://bugs.webkit.org/show_bug.cgi?id=184267
    
    Reviewed by Saam Barati.
    
    &lt;/snip&gt;
    
    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232261 268f45cc-cd09-0410-ab3c-d52691b4dbfc


Is bug 184267 a likely fix?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1650363</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2020-05-07 15:11:25 -0700</bug_when>
    <thetext>(In reply to Gary Kwong [:gkw] [:nth10sd] from comment #1)
&gt; Is bug 184267 a likely fix?

Thank you for tracking it down, Gary!

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

    </bug>

</bugzilla>