Closed Bug 1113685 Opened 5 years ago Closed 4 years ago

TypeError: function Call*MethodIfWrapped() is not a function


(Core :: JavaScript Engine, defect)

Not set



Tracking Status
firefox47 --- fixed


(Reporter: 446240525, Assigned: evilpie)


(Blocks 1 open bug)



(1 file, 1 obsolete file)

This doesn't look right:

js> (function*(){yield 1})(){})
typein:1:9 TypeError: CallStarGeneratorMethodIfWrapped method called on incompatible Object
js> newGlobal().eval("(function*(){yield 1})")(){})
typein:2:0 TypeError: function CallStarGeneratorMethodIfWrapped() {
typein:2:0     [native code]
typein:2:0 } is not a function


typein:4:0 TypeError: CallTypedArrayMethodIfWrapped method called on incompatible Object
js> newGlobal(){})
typein:5:0 TypeError: function CallTypedArrayMethodIfWrapped() {
typein:5:0     [native code]
typein:5:0 } is not a function
I know, kind of annoying to fix.
FWIW, I was also aware of this when I added the CallNonGenericSelfHostedMethod infrastructure and even discussed it with Jason:

15:32 <jandem>     jorendorff: ok that works beautifully; the CrossCompartmentWrapper generator test passes now. Just the error message is a bit confusing if you pass an incompatible object: CallLegacyGeneratorMethodIfWrapped method called on incompatible Array
15:33 <jorendorff> sold
15:33 <jorendorff> I literally do not care about that error message
Duplicate of this bug: 1242154
We should care about this error message.  A web developer running into this will have no clue what's going on and how to fix their code...
Assignee: nobody → evilpies
Attached patch WIP (obsolete) — Splinter Review
I almost got this working. However for the cross-compartment case we don't get the proper name.

> newGlobal(){})
TypeError: TypedArrayFindIndex method called on incompatible Object
TypeError: findIndex method called on incompatible Object

There must be some way to get the proper cloned function that already has the right name. Otherwise we could apply _SetCanonicalName to every function that uses CallXXXMethodIfWrapped.
Comment on attachment 8717565 [details] [diff] [review]

Review of attachment 8717565 [details] [diff] [review]:

Doesn't intrinsic_ActiveFunction do pretty much exactly what you want here? (In that it returns the function whose name is needed.)

If I'm not overlooking something, then just extracting that into a function called by intrinsic_ActiveFunction and ReportIncompatibleSelfHostedMethod would work, no?
\o/ ActiveFunction was the right idea, seems to be working now.
Attachment #8717565 - Attachment is obsolete: true
Attachment #8717658 - Flags: review?(till)
Comment on attachment 8717658 [details] [diff] [review]
Report the right name when calling selfhosted functions on incompatible objects

Review of attachment 8717658 [details] [diff] [review]:

Very nice, thank you! r=me with dead code removed.

::: js/src/vm/SelfHosting.cpp
@@ +1396,5 @@
> +    // because they always call the different CallXXXMethodIfWrapped methods,
> +    // which would be reported as the called function instead.
> +
> +    MOZ_ASSERT(args.length() > 0);
> +    RootedPropertyName name(cx, args[args.length() - 1].toString()->asAtom().asPropertyName());

This isn't used anymore.
Attachment #8717658 - Flags: review?(till) → review+
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Blocks: jserror
You need to log in before you can comment on or make changes to this bug.