Subj : Re: ++0 is not a syntax error? To : Igor Bukanov From : Brendan Eich Date : Wed Aug 18 2004 09:35 am Igor Bukanov wrote: > Hi! > > As far as I can see ECMAScript requires that ++0 should produce > RuntimeError, not SyntaxError. So, for example, the following should be OK: > > var f = Function('++0') > > and only during call to f RuntimeError should be generated. Microsoft > JScript and KDE JavaScript implementation follows this while > SpiderMonkey behaves much saner IMO and report SyntaxError during > parsing. But does ECMA-267 allow this early error reporting? > > Regards, Igor Yes, explicitly so, per Section 16 of ECMA-262 Edition 3: An implementation may treat any instance of the following kinds of runtime errors as a syntax error and therefore report it early: * Improper uses of return, break, and continue. * Using the eval property other than via a direct call. * Errors in regular expression literals. * Attempts to call PutValue on a value that is not a reference (for example, executing the assignment statement 3=4). The last is the one of interest here. /be .