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)

defect

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.
Here is a workaround for Florent: Components.classes["@mozilla.org/jsreflect;1"].createInstance()(); Reflect.parse("42", { builder: { program: function program() { return 24; } }});
Many thanks Jason for the workaround! Florent
Assignee: general → nobody
Severity: normal → S3
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.