Subj : Re: validate javascript To : john From : Brendan Eich Date : Mon Mar 17 2003 11:30 pm john wrote: >i am using latest Rhino >"john" wrote in message >news:b56f48$jjc1@ripley.netscape.com... > > >>var time=1; >>var distance=2 >>var cal = true; >> >>if(cal){ >>speed = distance/time; >>}else{ >>speed2222; >>} >> >>using evaluateString or compileReader it will not give error message >>"speed2222 is not defined ", unless cal is false. >> >>But if i change speed222 to speed 222 and cal=true, it will give >>error message" missing ; before statement", which is correct. >> >>Is this a bug or not? If not, how do i need validate this script. >> It's not a bug. Please read chapter 16 of ECMA-262 Edition 3 (http://www.mozilla.org/js/language/E262-3.pdf). If you want to validate, you'll have to extend Rhino's front end, or get someone else to do it, to make a program checker that assumes certain facts (that there is no speed2222 built-in property, whose getter has a useful side effect such that it makes sense to say 'speed2222;'). The SpiderMonkey engine supports a strict option that gives strict warnings for dubious constructions (for example, it will complain about the assignment to speed in the then statement, because speed has not been declared with var), but it does not assume that speed2222 is a mistake. It assumes you are referring to a property that will be found in the scope chain, with a useful side effect; or else that you want to cause a ReferenceError exception to be thrown. SpiderMonkey's strict warning option could be beefed up to assume more here. Someone bug me if you cares about this. /be >> >> >>Thanks, >>john >> >> >> >> >> >> >> >> >> >> > > > > .