Hi,

I was wrong... In 12.9 section in ECMAScript-262 spec can be read:

"An ECMAScript program is considered syntactically incorrect if it contains
a return statement that is not within a FunctionBody"

Ok... I'll try to find a workaround or to anlyze if we're abusing the use of
"return" in our application.

Cheers,

Iván


El 26 de julio de 2010 11:36, Iván Párraga García <
ivan.parraga.gar...@gmail.com> escribió:

> Hi,
>
> I'm embedding Rhino parser within our application and I've found the
> following problem: the parser throws a "invalid return" parse exception when
> the return statement is in the top scope (outside any function). For
> example, the following javascript program provokes 3 errors.
>
> var b = true;
> if(b) {
> return
> } else if (b<0) {
> return 5
> } else {
> return "bye"
> }
>
> If I'm not wrong, previous script is a valid Ecma program and our
> application uses this construct so I need to be able to parse it.
>
> Am I doing something wrongly? Do I need to set up some flag on the parser?
>
> Cheers,
>
> Iván
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
dev-tech-js-engine-rhino@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to