Backed out changeset 097da81cf423.

This commit is contained in:
Chris Leary 2011-02-11 18:59:20 -08:00
parent 302bd98617
commit f39f953a6e
3 changed files with 7 additions and 18 deletions

View File

@ -5797,7 +5797,12 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
#if JS_HAS_GENERATORS
case TOK_YIELD:
JS_ASSERT(cg->inFunction());
if (!cg->inFunction()) {
ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
JSMSG_BAD_RETURN_OR_YIELD,
js_yield_str);
return JS_FALSE;
}
if (pn->pn_kid) {
if (!js_EmitTree(cx, cg, pn->pn_kid))
return JS_FALSE;

View File

@ -4786,13 +4786,8 @@ Parser::returnOrYield(bool useAssignExpr)
return NULL;
#if JS_HAS_GENERATORS
if (tt == TOK_YIELD) {
if (!tc->inFunction()) {
reportErrorNumber(NULL, JSREPORT_ERROR, JSMSG_BAD_RETURN_OR_YIELD, js_yield_str);
return NULL;
}
if (tt == TOK_YIELD)
tc->flags |= TCF_FUN_IS_GENERATOR;
}
#endif
/* This is ugly, but we don't want to require a semicolon. */

View File

@ -390,17 +390,6 @@ assertStmt("try { } catch (e if foo) { } catch (e if bar) { } catch (e) { } fina
catchClause(ident("e"), null, blockStmt([])) ],
blockStmt([])));
// Bug 632028: yield outside of a function should throw
(function() {
var threw = false;
try {
Reflect.parse("yield 0");
} catch (expected) {
threw = true;
}
assertEq(threw, true);
})();
// redeclarations (TOK_NAME nodes with lexdef)
assertStmt("function f() { function g() { } function g() { } }",