Subj : Re: Failed to run script at optimization level higher than 0 To : Kok Hoor From : Igor Bukanov Date : Thu Dec 04 2003 11:16 am Kok Hoor wrote: > Hi all, > > I am trying to set optimization level higher than 0, and found > that the following Javascript failed to run. To ensure that I did > not initialize Rhino incorrectly, I tried running it using the Javascript > shell tool, but it failed as well. Below is the script: > > > function testConstructor() > { > this.value = ""; > } > > testConstructor.prototype.setValue = > function (value) > { > this.value = value; > } > > testConstructor.prototype.getValue = > function () > { > return this.value; > } > > function onLoad() > { > print("level 0"); > var test = new testConstructor(); > print("test : " + test); > test.setValue("hi"); > print(test.getValue()); > }; > > onLoad(); > > > Running it using the following command line: > > java -jar js.jar -opt 1 -version 150 -f test.js > > I got the following error: > > js: "test.js", line 23: uncaught JavaScript exception: > TypeError: undefined is not a function. (test.js; line 23) > > line 23 is: > > test.setValue("hi"); > > Apparently, the setValue function is left undefined. Is > this a bug? Or is it intended? The script works when > Optimization level is set to 0 or -1 It is a bug that was fixed in Rhino CVS. Try ftp://ftp.mozilla.org/pub/mozilla.org/js/rhinoLatest.zip Regards, Igor .