From 1cb352a508a3e272033fcb8ad89ebc4d372a7200 Mon Sep 17 00:00:00 2001 From: Brendan Eich Date: Sun, 10 May 2009 13:06:04 -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,