Bug 1083467 - Log console warnings for JavaScript 1.6's deprecated for-each-in loops. r=jorendorff

This commit is contained in:
Chris Peterson 2014-11-25 23:17:21 -08:00
parent 77859bbf03
commit ab8bf200bd
3 changed files with 20 additions and 8 deletions

View File

@ -4573,6 +4573,10 @@ Parser<FullParseHandler>::forStatement()
iflags = JSITER_FOREACH;
isForEach = true;
sawDeprecatedForEach = true;
if (versionNumber() < JSVERSION_LATEST) {
if (!report(ParseWarning, pc->sc->strict, null(), JSMSG_DEPRECATED_FOR_EACH))
return null();
}
}
}
@ -6755,8 +6759,14 @@ Parser<FullParseHandler>::legacyComprehensionTail(ParseNode *bodyExpr, unsigned
bool matched;
if (!tokenStream.matchContextualKeyword(&matched, context->names().each))
return null();
if (matched)
if (matched) {
pn2->pn_iflags |= JSITER_FOREACH;
sawDeprecatedForEach = true;
if (versionNumber() < JSVERSION_LATEST) {
if (!report(ParseWarning, pc->sc->strict, pn2, JSMSG_DEPRECATED_FOR_EACH))
return null();
}
}
}
MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_AFTER_FOR);
@ -8357,18 +8367,19 @@ Parser<ParseHandler>::accumulateTelemetry()
JS::AutoSuppressGCAnalysis nogc;
// Call back into Firefox's Telemetry reporter.
int id = JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT;
if (sawDeprecatedForEach)
cx->runtime()->addTelemetry(JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, DeprecatedForEach);
cx->runtime()->addTelemetry(id, DeprecatedForEach);
if (sawDeprecatedDestructuringForIn)
cx->runtime()->addTelemetry(JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, DeprecatedDestructuringForIn);
cx->runtime()->addTelemetry(id, DeprecatedDestructuringForIn);
if (sawDeprecatedLegacyGenerator)
cx->runtime()->addTelemetry(JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, DeprecatedLegacyGenerator);
cx->runtime()->addTelemetry(id, DeprecatedLegacyGenerator);
if (sawDeprecatedExpressionClosure)
cx->runtime()->addTelemetry(JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, DeprecatedExpressionClosure);
cx->runtime()->addTelemetry(id, DeprecatedExpressionClosure);
if (sawDeprecatedLetBlock)
cx->runtime()->addTelemetry(JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, DeprecatedLetBlock);
cx->runtime()->addTelemetry(id, DeprecatedLetBlock);
if (sawDeprecatedLetExpression)
cx->runtime()->addTelemetry(JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, DeprecatedLetExpression);
cx->runtime()->addTelemetry(id, DeprecatedLetExpression);
}
template class Parser<FullParseHandler>;

View File

@ -227,6 +227,7 @@ MSG_DEF(JSMSG_DECLARATION_AFTER_EXPORT,0, JSEXN_SYNTAXERR, "missing declaration
MSG_DEF(JSMSG_DECLARATION_AFTER_IMPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'import' keyword")
MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated")
MSG_DEF(JSMSG_DEPRECATED_LET_BLOCK, 0, JSEXN_NONE, "JavaScript 1.7's let blocks are deprecated")
MSG_DEF(JSMSG_DEPRECATED_FOR_EACH, 0, JSEXN_NONE, "JavaScript 1.6's for-each-in loops are deprecated; consider using ES6 for-of instead")
MSG_DEF(JSMSG_DEPRECATED_LET_EXPRESSION, 0, JSEXN_NONE, "JavaScript 1.7's let expressions are deprecated")
MSG_DEF(JSMSG_DEPRECATED_OCTAL, 0, JSEXN_SYNTAXERR, "octal literals and octal escape sequences are deprecated")
MSG_DEF(JSMSG_DEPRECATED_PRAGMA, 1, JSEXN_NONE, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead")

View File

@ -35,7 +35,7 @@ namespace js {
* Nightly) and without (all others). FIXME: Bug 1066322 - Enable ES6 symbols
* in all builds.
*/
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 220;
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 222;
static_assert(XDR_BYTECODE_VERSION_SUBTRAHEND % 2 == 0, "see the comment above");
static const uint32_t XDR_BYTECODE_VERSION =
uint32_t(0xb973c0de - (XDR_BYTECODE_VERSION_SUBTRAHEND