зеркало из https://github.com/mozilla/pjs.git
0794dcd8d7
Subject: Re: Rhino: [[DefaultValue]] missing for Call object Resent-Date: Mon, 2 Jul 2001 08:52:07 -0700 (PDT) Resent-From: mozilla-jseng@mozilla.org Date: Mon, 02 Jul 2001 11:49:59 -0400 From: Norris Boyd <nboyd@atg.com> Organization: Art Technology Group To: Christopher Oliver <coliver@mminternet.com> CC: mozilla-jseng@mozilla.org References: 1 I believe the correct result of the script should be [object global] [object Object] [object global] The activation object (which goes by the name of "Call" for historical reasons) should never be the 'this' value in a function call. See "10.1.6 Activation Object" in the ECMA spec. I'll look at fixing the problem for Rhino. If there's agreement on my analysis, someone should fix this for Spidermonkey too. --N Christopher Oliver wrote: > Hi, > > function a() { > function b() { > print(this); > } > this.f = function() { > print(this); > b(); > } > b(); > } > > var a = new a(); > a.f(); > > Running the above script with SpiderMonkey produces: > > [object global] > [object Object] > [object Call] > > Running with Rhino produces the following exception: > > uncaught JavaScript exception: undefined: Cannot find default value for > object. (line 3) > > This is due to a bug in org.mozilla.javascript.NativeCall which doesn't > implement toString or valueOf or override getDefaultValue. > However, even after I hacked in an implementation of getDefaultValue in > NativeCall, Rhino still produces a different result then spidermonkey: > > [object Call] > [object Object] > [object Call] |
||
---|---|---|
.. | ||
benchmarks | ||
js2 | ||
jsd | ||
jsdj | ||
jsj | ||
macbuild | ||
ref | ||
rhino | ||
semantics | ||
src | ||
tests | ||
.cvsignore | ||
Makefile.in | ||
landbranch.pl | ||
makefile.win |