зеркало из https://github.com/mozilla/pjs.git
Bug 497869 - Forbid let and yield in strict mode code in scripts which are not JS1.7 or greater (that is, any web script not explicitly opted into JS1.7+ with a <script type>). r=brendan
This commit is contained in:
Родитель
ccaa2e2118
Коммит
11e4b9c104
|
@ -1055,10 +1055,23 @@ TokenStream::getTokenInternal()
|
|||
JSMSG_RESERVED_ID, kw->chars)) {
|
||||
goto error;
|
||||
}
|
||||
} else if (kw->version <= VersionNumber(version)) {
|
||||
tt = kw->tokentype;
|
||||
tp->t_op = (JSOp) kw->op;
|
||||
goto out;
|
||||
} else {
|
||||
if (kw->version <= VersionNumber(version)) {
|
||||
tt = kw->tokentype;
|
||||
tp->t_op = (JSOp) kw->op;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* let/yield are a Mozilla extension starting in JS1.7. If we
|
||||
* aren't parsing for a version supporting these extensions,
|
||||
* conform to ES5 and forbid these names in strict mode.
|
||||
*/
|
||||
if ((kw->tokentype == TOK_LET || kw->tokentype == TOK_YIELD) &&
|
||||
!ReportStrictModeError(cx, this, NULL, NULL, JSMSG_RESERVED_ID, kw->chars))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,25 +14,27 @@ print(BUGNUMBER + ": " + summary);
|
|||
**************/
|
||||
|
||||
var futureReservedWords =
|
||||
["class",
|
||||
[
|
||||
"class",
|
||||
// "const", // Mozilla extension enabled even for versionless code
|
||||
"enum",
|
||||
"export",
|
||||
"extends",
|
||||
"import",
|
||||
"super"];
|
||||
"super",
|
||||
];
|
||||
|
||||
var strictFutureReservedWords =
|
||||
[
|
||||
"implements",
|
||||
"interface",
|
||||
// "let", // Mozilla extension, strict checks disabled for now
|
||||
"let", // enabled: this file doesn't execute as JS1.7
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"static",
|
||||
// "yield", // Mozilla extension, strict checks disabled for now
|
||||
"yield", // enabled: this file doesn't execute as JS1.7
|
||||
];
|
||||
|
||||
function testWord(word, expectNormal, expectStrict)
|
||||
|
|
Загрузка…
Ссылка в новой задаче