Closed Bug 547046 Opened 14 years ago Closed 14 years ago

the proper test whether an object can be called in IsCallable, not VALUE_IS_FUNCTION

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gal, Assigned: gal)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

The following doesn't work:

Function.prototype.apply.call(someRegExp, someRegExp, targetString)

This also affects other callable objects such as the proposed Harmony proxies.
Bug 539170 would probably fix this.

ES5 says regular expressions are callable?  :-(
Summary: TM: the proper test whether an object can be called in IsCallable, not VALUE_IS_FUNCTION → the proper test whether an object can be called in IsCallable, not VALUE_IS_FUNCTION
(In reply to comment #1)
> ES5 says regular expressions are callable?  :-(

ES5 does not specify a [[Call]] internal method for RegExp -- it's just like ES3. We should see about dropping callable regexps. Not sure how that will go down on the web, since IIRC WebKit followed us. Is there a bug on this?

/be
OS: Mac OS X → All
Hardware: x86 → All
(In reply to comment #0)
> The following doesn't work:
> 
> Function.prototype.apply.call(someRegExp, someRegExp, targetString)

IOW (followup on comment 2) this is just a handy test, not a normative spec thing.

/be
Assignee: general → gal
Attached patch patch (obsolete) — Splinter Review
Attached patch patchSplinter Review
Attachment #427732 - Attachment is obsolete: true
This fixes the two most obvious offenders. This blocks my proxy work, so I will get it reviewed and landed.
Attachment #427733 - Flags: review?(mrbkap)
Test case with proxies:

var proxy = Proxy.createFunction({ invoke: function(obj,name,args) { return Function.prototype[name].apply(obj, args); },
get: function(obj,name) { return Function.prototype[name]; } }, function () { return "ok"; });

print(proxy.call());

should print out "ok", without the patch the result is an error
Attachment #427733 - Flags: review?(mrbkap) → review+
http://hg.mozilla.org/tracemonkey/rev/16c93a834c66
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/16c93a834c66
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Blocks: 566818
No longer blocks: 566818
Depends on: 626050
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: