Evaluating a return statement (see bug URL) now results in an error: --------------------------------- SyntaxError: Invalid return statement. undefined --------------------------------- This causes many AppleScripts to fail, e.g. tell application "Safari" to do JavaScript "return 'qwerty';" in document 1
<rdar://problem/4673695>
It seems that according to §10.1.2 and §12.9 of the ECMAScript Language Spec, return statements are only valid in the context of a FunctionBody. An eval statement is the equivalent of script executing in the context of a global scope, and as such "return" is invalid. So even though this is a regression in the sense that release Safari does not complain, the ToT behavior is the correct behavior for specification conformance. I additionally tested the script in Firefox and IE7, and both browsers similarly complained about a return statement outside of a function. So given the behavior of other browsers and the spec, this bug should probably be resolved as invalid.
Based on Sanjay's comment I am closing this as INVALID. If this affects any major real-world applications or sites we should revisit this, otherwise the new behaviour is closer to the specification.