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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>20731</bug_id>
          
          <creation_ts>2013-01-22 11:51:16 +0000</creation_ts>
          <short_desc>Sequence algorithm seems incorrect</short_desc>
          <delta_ts>2013-01-22 17:24:20 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>WebIDL</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Marcos Caceres">w3c</reporter>
          <assigned_to name="Cameron McCormack">cam</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>mike</cc>
    
    <cc>public-script-coord</cc>
    
    <cc>w3c</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>81925</commentid>
    <comment_count>0</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2013-01-22 11:51:16 +0000</bug_when>
    <thetext>Reading http://dev.w3.org/2006/webapi/WebIDL/#es-sequence

Where the algorithm goes: 

&quot;
Let n be the result of calling ToUint32(length).
Initialize S0..n−1 to be an IDL sequence with elements of type T, where each element is uninitialized.
While i &lt; n:
Let P be the result of calling ToString(i).
Let E be the result of calling [[Get]] on V with property name P.
&quot;

P will just be &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, and so on, but not the actual property name. And hence E will just be undefined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81931</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-01-22 13:07:56 +0000</bug_when>
    <thetext>What do you mean by &quot;actual property name&quot;?

In ECMAScript, all property names are strings.  So for example the array [ &quot;a&quot;, &quot;b&quot; ] has properties named &quot;0&quot; and &quot;1&quot; (as well as &quot;length&quot;).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81932</commentid>
    <comment_count>2</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2013-01-22 13:21:25 +0000</bug_when>
    <thetext>You are correct, but how does this work if the object passed is:

{foo: &quot;x&quot;, bar: &quot;y&quot;}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81933</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-01-22 13:25:13 +0000</bug_when>
    <thetext>Then it doesn&apos;t have indexed properties, right?  And no length, either.  So in terms of conversion to a sequence it&apos;s exactly the same as passing in the empty array [].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81938</commentid>
    <comment_count>4</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2013-01-22 16:26:04 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Then it doesn&apos;t have indexed properties, right?  And no length, either.  So
&gt; in terms of conversion to a sequence it&apos;s exactly the same as passing in the
&gt; empty array [].

ah, ok. In the case of [[Get]] length being ``undefined`` calling `ToUint32(length)` converts it to a +0.

Thanks for clarifying, Boris. Closing as invalid.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81939</commentid>
    <comment_count>5</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2013-01-22 16:49:45 +0000</bug_when>
    <thetext>Just one more minor thing (which may be JS implementation specific)... calling new Array(-1) causes Array to throw a &quot;RangeError: Invalid array length&quot;, as happens in the following case: 

length = undefined; 

//Let n be the result of calling ToUint32(length).
n = ToUint32(length); //0

//Initialize S[0..n−1] to be an IDL sequence with elements of type T,
//where each element is uninitialized.
S = new Array(n - 1);

Does that matter?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81942</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-01-22 17:05:03 +0000</bug_when>
    <thetext>&gt; S = new Array(n - 1);

That line of code is just wrong, no?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81944</commentid>
    <comment_count>7</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2013-01-22 17:08:43 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; &gt; S = new Array(n - 1);
&gt; 
&gt; That line of code is just wrong, no?

Dunno. I&apos;m just doing what the spec says.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81947</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-01-22 17:12:30 +0000</bug_when>
    <thetext>No, you&apos;re not.  You&apos;re passing in the wrong length.  The correct thing to pass in is &quot;n&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81950</commentid>
    <comment_count>9</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2013-01-22 17:20:29 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; No, you&apos;re not.  You&apos;re passing in the wrong length.  The correct thing to
&gt; pass in is &quot;n&quot;.

ah, got thrown by the &quot;..n−1&quot; bit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81951</commentid>
    <comment_count>10</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-01-22 17:24:20 +0000</bug_when>
    <thetext>Right, the indices range from 0 to n-1.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>