Bug fixes and baselines

This commit is contained in:
Ron Buckton
2015-05-07 11:13:45 -07:00
parent e82e8419c2
commit 80edb2de4a
22 changed files with 104 additions and 133 deletions

View File

@@ -592,7 +592,7 @@ module ts {
// no need to do anything special as we are already in all of the requested contexts
return func();
}
function allowInAnd<T>(func: () => T): T {
return doOutsideOfContext(ParserContextFlags.DisallowIn, func);
}
@@ -621,12 +621,16 @@ module ts {
return doOutsideOfContext(ParserContextFlags.Await, func);
}
function doInYieldAndAwaitContext<T>(func: () => T): T {
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
}
function doOutsideOfYieldAndAwaitContext<T>(func: () => T): T {
return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
}
function inContext(flags: ParserContextFlags) {
return (contextFlags & flags) === flags;
return (contextFlags & flags) !== 0;
}
function inYieldContext() {
@@ -957,8 +961,8 @@ module ts {
// says that only an assignment expression is allowed, so the grammar checker
// will error if it sees a comma expression.
node.expression = inGeneratorParameterOrAsyncParameterContext()
? doOutsideOfYieldAndAwaitContext(parseExpression)
: parseExpression();
? doOutsideOfYieldAndAwaitContext(allowInAndParseExpression)
: allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseBracketToken);
return finishNode(node);
@@ -1857,8 +1861,8 @@ module ts {
function parseParameter(): ParameterDeclaration {
let node = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
node.decorators = parseDecorators();
setModifiers(node, parseModifiers());
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
setModifiers(node, parseModifiers());
// FormalParameter[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.1
// BindingElement[?Yield,?GeneratorParameter,?Await,?AsyncParameter]
@@ -1901,7 +1905,6 @@ module ts {
// [+GeneratorParameter] BindingIdentifier[Yield] Initializer[In]opt
// [+AsyncParameter] BindingIdentifier[Await] Initializer[In]opt
// [~GeneratorParameter,~AsyncParameter] BindingIdentifier[?Yield,?Await] Initializer[In,?Yield,?Await]opt
let parseInitializer = inParameter ? parseParameterInitializer : parseNonParameterInitializer;
return inGeneratorParameterOrAsyncParameterContext()
? doOutsideOfYieldAndAwaitContext(parseInitializer)
@@ -1957,27 +1960,19 @@ module ts {
let savedGeneratorParameterContext = inGeneratorParameterContext();
let savedAwaitContext = inAwaitContext();
let savedAsyncParameterContext = inAsyncParameterContext();
if (yieldAndGeneratorParameterContext) {
setYieldContext(true);
}
setYieldContext(yieldAndGeneratorParameterContext);
setGeneratorParameterContext(yieldAndGeneratorParameterContext);
if (awaitAndAsyncParameterContext) {
setAwaitContext(true);
}
setAwaitContext(awaitAndAsyncParameterContext);
setAsyncParameterContext(awaitAndAsyncParameterContext);
let result = parseDelimitedList(ParsingContext.Parameters, parseParameter);
setYieldContext(savedYieldContext);
setGeneratorParameterContext(savedGeneratorParameterContext);
setAwaitContext(savedAwaitContext);
setAsyncParameterContext(savedAsyncParameterContext);
if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) {
// Caller insisted that we had to end with a ) We didn't. So just return
// undefined here.
@@ -1992,7 +1987,7 @@ module ts {
// then just return an empty set of parameters.
return requireCompleteParameterList ? undefined : createMissingList<ParameterDeclaration>();
}
function parseTypeMemberSemicolon() {
// We allow type members to be separated by commas or (possibly ASI) semicolons.
// First check if it was a comma. If so, we're done with the member.
@@ -2368,7 +2363,7 @@ module ts {
function parseType(): TypeNode {
// The rules about 'yield' only apply to actual code/expression contexts. They don't
// apply to 'type' contexts. So we disable these parameters here before moving on.
return doOutsideOfContext(ParserContextFlags.ContextParameterFlags, parseTypeWorker);
return doOutsideOfContext(ParserContextFlags.AllParameterFlags, parseTypeWorker);
}
function parseTypeWorker(): TypeNode {
@@ -2455,6 +2450,10 @@ module ts {
token !== SyntaxKind.AtToken &&
isStartOfExpression();
}
function allowInAndParseExpression(): Expression {
return allowInAnd(parseExpression);
}
function parseExpression(): Expression {
// Expression[in]:
@@ -3449,20 +3448,15 @@ module ts {
let node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression);
setModifiers(node, parseModifiers());
parseExpected(SyntaxKind.FunctionKeyword);
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
let savedYieldContext = inYieldContext();
let isGenerator = node.asteriskToken != undefined;
setYieldContext(isGenerator);
let savedAwaitContext = inAwaitContext();
let isAsync = isAsyncFunctionLike(node);
setAwaitContext(isAsync);
node.name = parseOptionalIdentifier();
setYieldContext(savedYieldContext);
setAwaitContext(savedAwaitContext);
node.name =
isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
parseOptionalIdentifier();
fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false);

View File

@@ -359,7 +359,9 @@ module ts {
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | AsyncParameter | Await,
// Context flags passed as part of the modified ES6 grammar.
ContextParameterFlags = Yield | GeneratorParameter | AsyncParameter | Await,
YieldAndGeneratorParameterFlags = Yield | GeneratorParameter,
AwaitAndAsyncParameterFlags = Await | AsyncParameter,
AllParameterFlags = YieldAndGeneratorParameterFlags | AwaitAndAsyncParameterFlags,
// Context flags computed by aggregating child flags upwards.

View File

@@ -75,26 +75,26 @@ function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
switch (node.kind) {
case 187 /* ForStatement */:
case 188 /* ForInStatement */:
case 186 /* WhileStatement */:
case 185 /* DoStatement */:
if (node.statement.kind !== 180 /* Block */) {
case 190 /* ForStatement */:
case 191 /* ForInStatement */:
case 189 /* WhileStatement */:
case 188 /* DoStatement */:
if (node.statement.kind !== 183 /* Block */) {
report(node, "A looping statement's contents should be wrapped in a block body.");
}
break;
case 184 /* IfStatement */:
case 187 /* IfStatement */:
var ifStatement = node;
if (ifStatement.thenStatement.kind !== 180 /* Block */) {
if (ifStatement.thenStatement.kind !== 183 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement &&
ifStatement.elseStatement.kind !== 180 /* Block */ &&
ifStatement.elseStatement.kind !== 184 /* IfStatement */) {
ifStatement.elseStatement.kind !== 183 /* Block */ &&
ifStatement.elseStatement.kind !== 187 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
case 170 /* BinaryExpression */:
case 173 /* BinaryExpression */:
var op = node.operatorToken.kind;
if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) {
report(node, "Use '===' and '!=='.");

View File

@@ -1,20 +1,8 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ====
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ====
function * foo(a = yield => yield) {
~~~~~~~~~
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
~~
!!! error TS1005: ',' expected.
~~~~~
!!! error TS1138: Parameter declaration expected.
~~~~~
!!! error TS2304: Cannot find name 'yield'.
~
!!! error TS1005: ';' expected.
~
!!! error TS9001: Generators are not currently supported.
}

View File

@@ -1,5 +1,5 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ====
@@ -7,5 +7,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,1
~
!!! error TS9001: Generators are not currently supported.
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
!!! error TS2304: Cannot find name 'yield'.
}

View File

@@ -1,6 +1,6 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ====
@@ -12,6 +12,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,2
~
!!! error TS9001: Generators are not currently supported.
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
!!! error TS2304: Cannot find name 'yield'.
}
}

View File

@@ -1,9 +1,9 @@
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,27): error TS1109: Expression expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,22): error TS2304: Cannot find name 'await'.
==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts (1 errors) ====
var foo = async (a = await): Promise<void> => {
~
!!! error TS1109: Expression expected.
~~~~~
!!! error TS2304: Cannot find name 'await'.
}

View File

@@ -4,5 +4,5 @@ var foo = async (a = await): Promise<void> => {
}
//// [asyncArrowFunction6_es6.js]
var foo = (...arguments_1) => __awaiter(function *(a = yield ) {
var foo = (...arguments_1) => __awaiter(function *(a = await) {
}.apply(this, arguments_1), Promise);

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,29): error TS1109: Expression expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,24): error TS2304: Cannot find name 'await'.
==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts (1 errors) ====
@@ -6,7 +6,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(
var bar = async (): Promise<void> => {
// 'await' here is an identifier, and not an await expression.
var foo = async (a = await): Promise<void> => {
~
!!! error TS1109: Expression expected.
~~~~~
!!! error TS2304: Cannot find name 'await'.
}
}

View File

@@ -9,6 +9,6 @@ var bar = async (): Promise<void> => {
//// [asyncArrowFunction7_es6.js]
var bar = () => __awaiter(function *() {
// 'await' here is an identifier, and not an await expression.
var foo = (...arguments_1) => __awaiter(function *(a = yield ) {
var foo = (...arguments_1) => __awaiter(function *(a = await) {
}.apply(this, arguments_1), Promise);
}.apply(this), Promise);

View File

@@ -1,23 +0,0 @@
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected.
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected.
==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts (6 errors) ====
var foo = async (a = await => await): Promise<void> => {
~~~~~
!!! error TS2304: Cannot find name 'async'.
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS1005: ',' expected.
~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'.
~
!!! error TS1005: '=' expected.
~~
!!! error TS1109: Expression expected.
}

View File

@@ -3,6 +3,5 @@ var foo = async (a = await => await): Promise<void> => {
}
//// [asyncArrowFunction9_es6.js]
var foo = async(a = await => await), Promise = ;
{
}
var foo = (...arguments_1) => __awaiter(function *(a = await => await) {
}.apply(this, arguments_1), Promise);

View File

@@ -0,0 +1,8 @@
=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts ===
var foo = async (a = await => await): Promise<void> => {
>foo : Symbol(foo, Decl(asyncArrowFunction9_es6.ts, 0, 3))
>a : Symbol(a, Decl(asyncArrowFunction9_es6.ts, 0, 17))
>await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20))
>await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11))
}

View File

@@ -0,0 +1,10 @@
=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts ===
var foo = async (a = await => await): Promise<void> => {
>foo : (a?: (await: any) => any) => Promise<void>
>async (a = await => await): Promise<void> => {} : (a?: (await: any) => any) => Promise<void>
>a : (await: any) => any
>await => await : (await: any) => any
>await : any
>await : any
>Promise : Promise<T>
}

View File

@@ -1,26 +0,0 @@
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected.
==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ====
async function foo(a = await => await): Promise<void> {
~~~~~~~~~
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
~~
!!! error TS1109: Expression expected.
~~~~~
!!! error TS1138: Parameter declaration expected.
~~~~~
!!! error TS2304: Cannot find name 'await'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1109: Expression expected.
}

View File

@@ -3,5 +3,7 @@ async function foo(a = await => await): Promise<void> {
}
//// [asyncFunctionDeclaration10_es6.js]
await;
Promise < void > {};
function foo() {
return __awaiter(function *(a = await => await) {
}.apply(this, arguments), Promise);
}

View File

@@ -0,0 +1,8 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts ===
async function foo(a = await => await): Promise<void> {
>foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es6.ts, 0, 0))
>a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19))
>await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22))
>await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11))
}

View File

@@ -0,0 +1,9 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts ===
async function foo(a = await => await): Promise<void> {
>foo : (a?: (await: any) => any) => Promise<void>
>a : (await: any) => any
>await => await : (await: any) => any
>await : any
>await : any
>Promise : Promise<T>
}

View File

@@ -1,8 +1,8 @@
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,29): error TS1109: Expression expected.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,24): error TS2304: Cannot find name 'await'.
==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts (1 errors) ====
async function foo(a = await): Promise<void> {
~
!!! error TS1109: Expression expected.
~~~~~
!!! error TS2304: Cannot find name 'await'.
}

View File

@@ -4,6 +4,6 @@ async function foo(a = await): Promise<void> {
//// [asyncFunctionDeclaration6_es6.js]
function foo() {
return __awaiter(function *(a = yield ) {
return __awaiter(function *(a = await) {
}.apply(this, arguments), Promise);
}

View File

@@ -1,11 +1,11 @@
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,31): error TS1109: Expression expected.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,26): error TS2304: Cannot find name 'await'.
==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts (1 errors) ====
async function bar(): Promise<void> {
// 'await' here is an identifier, and not a yield expression.
async function foo(a = await): Promise<void> {
~
!!! error TS1109: Expression expected.
~~~~~
!!! error TS2304: Cannot find name 'await'.
}
}

View File

@@ -10,7 +10,7 @@ function bar() {
return __awaiter(function *() {
// 'await' here is an identifier, and not a yield expression.
function foo() {
return __awaiter(function *(a = yield ) {
return __awaiter(function *(a = await) {
}.apply(this, arguments), Promise);
}
}.apply(this, arguments), Promise);