Bug 64900 - Function.prototype.apply should accept an array-like object as its second argument
Summary: Function.prototype.apply should accept an array-like object as its second arg...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Gavin Barraclough
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-20 16:05 PDT by Kit Cambridge
Modified: 2011-07-21 11:59 PDT (History)
3 users (show)

See Also:


Attachments
The patch (8.58 KB, patch)
2011-07-21 11:45 PDT, Gavin Barraclough
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kit Cambridge 2011-07-20 16:05:49 PDT
Overview
========
According to section 15.3.4.3 of the spec, `Function.prototype.apply` should accept an array-like object as its second argument. See steps 2 and 3:

> 2. If Type(argArray) is not Object, then throw a TypeError exception.
> 3. Let len be the result of calling the [[Get]] internal method of argArray with argument "length".

As of the latest WebKit nightly, invocations such as `(function(){}).apply(null, {length: 0})` throw a `TypeError`. This is inconsistent with the above algorithm.

Steps to Reproduce
==================

1) Open the Web Inspector.
2) Enter `(function(){ return [].slice.call(arguments); }).apply(null, {0: 1, 1: 2, length: 2})`.

Actual Results
==============

A `TypeError` is thrown.

Expected Results
================

The function should return `[1, 2]`.
Comment 1 Gavin Barraclough 2011-07-21 11:45:40 PDT
Created attachment 101618 [details]
The patch
Comment 2 Gavin Barraclough 2011-07-21 11:58:13 PDT
Fixed in r91482
Comment 3 Gavin Barraclough 2011-07-21 11:59:56 PDT
Ooops, r91483