Closed
Bug 950853
Opened 12 years ago
Closed 2 years ago
Reflect.parse: support builder methods that are callable but not JSFunctions
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: jorendorff, Unassigned)
Details
The following doesn't work in a Browser Scratchpad:
Components.utils.import("resource://gre/modules/reflect.jsm") ;
Reflect.parse("42", { builder: {
program: function program() {
return 24;
}
}});
It gives the error "(function program() {
return 24;
}) is not a function".
This is because what is actually passed to Reflect.parse is a transparent wrapper around the builder object, triggering this code in NodeBuilder::init:
if (!funv.isObject() || !funv.toObject().is<JSFunction>()) {
js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_NOT_FUNCTION,
JSDVG_SEARCH_STACK, funv, js::NullPtr(), nullptr, nullptr);
return false;
}
Transparent wrappers around JSFunctions are not JSFunctions.
Reported by Florent Fayolle.
| Reporter | ||
Comment 1•12 years ago
|
||
Here is a workaround for Florent:
Components.classes["@mozilla.org/jsreflect;1"].createInstance()();
Reflect.parse("42", { builder: {
program: function program() {
return 24;
}
}});
Comment 2•12 years ago
|
||
Many thanks Jason for the workaround!
Florent
| Assignee | ||
Updated•11 years ago
|
Assignee: general → nobody
Updated•3 years ago
|
Severity: normal → S3
Updated•2 years ago
|
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•