From 6edeca700a0195ab7c2ff4ef153cf0aa144c733a Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Thu, 30 Jun 2005 22:20:05 +0000 Subject: [PATCH] Fix for 299209, a=jay. git-svn-id: svn://10.0.0.236/branches/AVIARY_1_0_1_20050124_BRANCH@175428 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsparse.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mozilla/js/src/jsparse.c b/mozilla/js/src/jsparse.c index dbb892e912a..b6aacbf0862 100644 --- a/mozilla/js/src/jsparse.c +++ b/mozilla/js/src/jsparse.c @@ -738,10 +738,12 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, #endif /* Scan the optional function name into funAtom. */ - if (js_MatchToken(cx, ts, TOK_NAME)) - funAtom = CURRENT_TOKEN(ts).t_atom; - else - funAtom = NULL; + funAtom = js_MatchToken(cx, ts, TOK_NAME) ? CURRENT_TOKEN(ts).t_atom : NULL; + if (!funAtom && !lambda) { + js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, + JSMSG_SYNTAX_ERROR); + return NULL; + } /* Find the nearest variable-declaring scope and use it as our parent. */ parent = cx->fp->varobj; @@ -926,13 +928,14 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, } #if JS_HAS_LEXICAL_CLOSURE - if (lambda || !funAtom) { + JS_ASSERT(lambda || funAtom); + if (lambda) { /* * ECMA ed. 3 standard: function expression, possibly anonymous (even * if at top-level, an unnamed function is an expression statement, not * a function declaration). */ - op = fun->atom ? JSOP_NAMEDFUNOBJ : JSOP_ANONFUNOBJ; + op = funAtom ? JSOP_NAMEDFUNOBJ : JSOP_ANONFUNOBJ; } else if (tc->topStmt) { /* * ECMA ed. 3 extension: a function expression statement not at the