Bug 738617 - Revert changeset 6d139ebc0f43 (bug 730139). Reserving let breaks some web sites. r=Waldo, a=mfinkle.

This commit is contained in:
Jason Orendorff 2012-04-18 15:07:11 -05:00
parent 02682d2114
commit e126ffe211
7 changed files with 10 additions and 28 deletions

View File

@ -113,7 +113,7 @@ function report(testName, success) {
]]></script>
<script type="text/javascript"><![CDATA[
try {
eval("let (x=1) (x)");
let (x=1) (x);
var success = false;
}
catch (e) { success = true; }

View File

@ -1323,18 +1323,12 @@ TokenStream::checkForKeyword(const jschar *s, size_t length, TokenKind *ttp, JSO
JSMSG_RESERVED_ID, kw->chars);
}
/* The let keyword is reserved on <1.7 */
if (kw->tokentype == TOK_LET) {
return ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
JSMSG_RESERVED_ID, kw->chars);
}
/*
* The keyword is not in this version. Treat it as an identifier,
* unless it is yield which we treat as TOK_STRICT_RESERVED by
* falling through to the code below (ES5 forbids it in strict mode).
* unless it is let or yield which we treat as TOK_STRICT_RESERVED by
* falling through to the code below (ES5 forbids them in strict mode).
*/
if (kw->tokentype != TOK_YIELD)
if (kw->tokentype != TOK_LET && kw->tokentype != TOK_YIELD)
return true;
}

View File

@ -9,7 +9,7 @@ function addTestCase( t ) {\
SECTION,\
'(new Date('+d+')).getUTCDay()',\
WeekDay((d)),\
(new Date(foo ({ stop } = 'properties.length' )('/ab[c\\\n]/'))).getUTCDay() \
(new Date(let ({ stop } = 'properties.length' )('/ab[c\\\n]/'))).getUTCDay() \
);\
}\
");

View File

@ -21,7 +21,6 @@ var futureReservedWords =
"export",
"extends",
"import",
"let", // Reserved even for versionless code, contrary to ES5 - see bug 730139
"super",
];
@ -29,6 +28,7 @@ var strictFutureReservedWords =
[
"implements",
"interface",
"let", // enabled: this file doesn't execute as JS1.7
"package",
"private",
"protected",

View File

@ -1,14 +0,0 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
var actual = 'No error';
try {
eval("var let = true");
} catch (exc) {
actual = exc + '';
}
reportCompare('SyntaxError: let is a reserved identifier', actual, 'ok');

View File

@ -47,6 +47,7 @@ test();
//-----------------------------------------------------------------------------
yield = 1;
let = 1;
function test()
{
@ -54,9 +55,10 @@ function test()
printBugNumber(BUGNUMBER);
printStatus (summary);
function f(yield) { return yield; }
function f(yield, let) { return yield+let; }
var yield = 1;
var let = 1;
function yield() {}

View File

@ -52,7 +52,7 @@ function test()
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = 'SyntaxError: let is a reserved identifier';
expect = 'SyntaxError: invalid for each loop';
try
{
var obj = { };