Back out bc75fd3095eb (bug 907958), the simple rebasing through bug 666399 is busted. Probably a simple-ish fix, not gonna try it on a deadline, tho. r=beep-beep-beep from a CLOSED TREE

This commit is contained in:
Jeff Walden 2013-08-23 19:27:30 -07:00
parent caecd047a6
commit 234e8e440a
7 changed files with 102 additions and 31 deletions

View File

@ -2446,7 +2446,7 @@ Parser<ParseHandler>::functionStmt()
RootedPropertyName name(context);
GeneratorKind generatorKind = NotGenerator;
TokenKind tt = tokenStream.getToken();
TokenKind tt = tokenStream.getToken(TokenStream::KeywordIsName);
if (tt == TOK_MUL) {
tokenStream.tell(&start);
@ -2481,7 +2481,7 @@ Parser<ParseHandler>::functionExpr()
RootedPropertyName name(context);
GeneratorKind generatorKind = NotGenerator;
TokenKind tt = tokenStream.getToken();
TokenKind tt = tokenStream.getToken(TokenStream::KeywordIsName);
if (tt == TOK_MUL) {
tokenStream.tell(&start);

View File

@ -4588,7 +4588,7 @@ ParseFunction(ModuleCompiler &m, ParseNode **fnOut)
DebugOnly<TokenKind> tk = tokenStream.getToken();
JS_ASSERT(tk == TOK_FUNCTION);
if (tokenStream.getToken() != TOK_NAME)
if (tokenStream.getToken(TokenStream::KeywordIsName) != TOK_NAME)
return false; // This will throw a SyntaxError, no need to m.fail.
RootedPropertyName name(m.cx(), tokenStream.currentToken().name());

View File

@ -37,7 +37,7 @@ var strictFutureReservedWords =
"yield", // enabled: this file doesn't execute as JS1.7
];
function testWord(word, expectNormal, expectStrict)
function testWord(word, wordKind, expectNormal, expectStrict)
{
var actual, status;
@ -355,19 +355,22 @@ function testWord(word, expectNormal, expectStrict)
// USE AS FUNCTION NAME IN FUNCTION DECLARATION
actual = "";
status = summary + ": " + word + ": normal function name";
try
if (wordKind !== "reserved")
{
eval("function " + word + "() { }");
actual = "no error";
actual = "";
status = summary + ": " + word + ": normal function name";
try
{
eval("function " + word + "() { }");
actual = "no error";
}
catch (e)
{
actual = e.name;
status += ", " + e.name + ": " + e.message + " ";
}
reportCompare(expectNormal, actual, status);
}
catch (e)
{
actual = e.name;
status += ", " + e.name + ": " + e.message + " ";
}
reportCompare(expectNormal, actual, status);
actual = "";
status = summary + ": " + word + ": strict function name";
@ -399,19 +402,22 @@ function testWord(word, expectNormal, expectStrict)
// USE AS FUNCTION NAME IN FUNCTION EXPRESSION
actual = "";
status = summary + ": " + word + ": normal function expression name";
try
if (wordKind !== "reserved")
{
eval("var s = (function " + word + "() { });");
actual = "no error";
actual = "";
status = summary + ": " + word + ": normal function expression name";
try
{
eval("var s = (function " + word + "() { });");
actual = "no error";
}
catch (e)
{
actual = e.name;
status += ", " + e.name + ": " + e.message + " ";
}
reportCompare(expectNormal, actual, status);
}
catch (e)
{
actual = e.name;
status += ", " + e.name + ": " + e.message + " ";
}
reportCompare(expectNormal, actual, status);
actual = "";
status = summary + ": " + word + ": strict function expression name";
@ -444,12 +450,12 @@ function testWord(word, expectNormal, expectStrict)
function testFutureReservedWord(word)
{
testWord(word, "SyntaxError", "SyntaxError");
testWord(word, "reserved", "SyntaxError", "SyntaxError");
}
function testStrictFutureReservedWord(word)
{
testWord(word, "no error", "SyntaxError");
testWord(word, "strict reserved", "no error", "SyntaxError");
}
futureReservedWords.forEach(testFutureReservedWord);

View File

@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 343675;
var summary = 'Allow keywords, reserved words as function names';
var actual = '';
var expect = 'No Error';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
var words = [
'break', 'else', 'new', 'var', 'case', 'finally', 'return', 'void',
'catch', 'for', 'switch', 'while', 'continue', 'function', 'this',
'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'do',
'instanceof', 'typeof',
'abstract', 'enum', 'int', 'short', 'boolean', 'export', 'interface',
'static', 'byte', 'extends', 'long', 'super', 'char', 'final', 'native',
'synchronized', 'class', 'float', 'package', 'throws', 'const', 'goto',
'private', 'transient', 'debugger', 'implements', 'protected', 'volatile',
'double', 'import', 'public'];
for (var i = 0; i < words.length; i++)
{
try
{
actual = 'No Error';
eval('function ' + words[i] + '() {}');
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary + ': ' + words[i]);
}
exitFunc ('test');
}

View File

@ -93,5 +93,17 @@ function test()
}
reportCompare(expect, actual, summary + ': function () { var let;}');
try
{
expect = 'No Error';
function yield() {}
actual = 'No Error';
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary + ': function yield()');
exitFunc ('test');
}

View File

@ -36,7 +36,11 @@ function test()
// Assertion failure: !pn->isPlaceholder(), at ../jsparse.cpp:4876
// =====
(function(){ var x; eval("var x; x = null"); })();
(function(){ var x; eval("var x; x = null"); })()
// Assertion failure: regs.sp == StackBase(fp), at ../jsinterp.cpp:2984
// =====
function this ({x}) { function x(){} }
// Assertion failure: !(pnu->pn_dflags & PND_BOUND), at ../jsemit.cpp:1818
// =====

View File

@ -111,7 +111,7 @@ ServerBSO.prototype = {
return obj;
},
delete: function delete_() {
delete: function delete() {
this.deleted = true;
delete this.payload;
@ -571,7 +571,7 @@ StorageServerCollection.prototype = {
return {success: success, failed: failed};
},
delete: function delete_(options) {
delete: function delete(options) {
options = options || {};
// Protocol 2.0 only allows the "ids" query string argument.