From d2eca49e6bf060054fb641991ebe988c4e66057f Mon Sep 17 00:00:00 2001 From: Brendan Eich Date: Sun, 10 May 2009 12:52:03 -0700 Subject: [PATCH] Bug 492150 - Unexpected error occurred when japascript.options.strict is true (r=mrbkap). --- js/src/jsparse.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/src/jsparse.cpp b/js/src/jsparse.cpp index cadc269b108..7f4490d2aac 100644 --- a/js/src/jsparse.cpp +++ b/js/src/jsparse.cpp @@ -2030,7 +2030,7 @@ JSCompiler::setFunctionKinds(JSFunctionBox *funbox, uint16& tcflags) /* * Watch out for code such as - * + * * (function () { * ... * var jQuery = ... = function (...) { @@ -3049,18 +3049,18 @@ BindVarOrConst(JSContext *cx, BindData *data, JSAtom *atom, JSTreeContext *tc) return JS_FALSE; } } else { + bool error = (op == JSOP_DEFCONST || + dn_kind == JSDefinition::CONST || + (dn_kind == JSDefinition::LET && + (stmt->type != STMT_CATCH || OuterLet(tc, stmt, atom)))); + if (JS_HAS_STRICT_OPTION(cx) ? op != JSOP_DEFVAR || dn_kind != JSDefinition::VAR - : op == JSOP_DEFCONST || - dn_kind == JSDefinition::CONST || - (dn_kind == JSDefinition::LET && - (stmt->type != STMT_CATCH || OuterLet(tc, stmt, atom)))) { + : error) { name = js_AtomToPrintableString(cx, atom); if (!name || !js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn, - (op != JSOP_DEFCONST && - dn_kind != JSDefinition::CONST && - dn_kind != JSDefinition::LET) + !error ? JSREPORT_WARNING | JSREPORT_STRICT : JSREPORT_ERROR, JSMSG_REDECLARED_VAR,