Re: Object creation in SpiderMonkey 45
Mihai Dobrescu <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
On Thursday, May 5, 2016 at 8:21:04 PM UTC+3, Boris Zbarsky wrote: > On 5/5/16 12:50 PM, Mihai Dobrescu wrote: > > On Thursday, May 5, 2016 at 7:38:32 PM UTC+3, Mihai Dobrescu wrote: > >> On Thursday, May 5, 2016 at 7:27:05 PM UTC+3, Boris Zbarsky wrote: > >>> Things used to default to "if you pass no prototype and just the class > >>> we'll do some fragile lookup to try to figure out the right prototype", > >>> but that went away in https://bugzilla.mozilla.org/show_bug.cgi?id=1125567 > >>> > >>> So you need to pass in the right prototype object here. > >>> > >>> -Boris > >> > >> I don't understand what you mean. It is 45, not 38. > > > > + I used to pass nullptr for prototype, in 38, and it worked. > > Sure. It worked because JS_NewObject saw you passed null for the proto > but a non-default class, took the class name, looked it up as a property > on the global, assumed the result was the constructor for your class, > got its .prototype and used that as the prototype. > > That whole "look up the name on the global and hope it has something to > do with us" thing was removed in the bug I link to above, which was > fixed in Firefox 40. Notably, 38 < 40 <= 45. > > > I would expect that after initialization of classes, all the stuff to work as their definitions are loaded, including their functions. > > The definitions are "loaded". The functions are defined on the > prototype object for your class. But the object you're creating doesn't > have that on its proto chain, because of the behavior change above. > > -Boris My mind just blown up. What is the status now in 45? Is it a bug, or should I do things differently? If so, how?