Merge pull request #1261 from Microsoft/contextFlags
Use a separate field on a node to specify parser context flags.
This commit is contained in:
commit
af4a12151c
|
@ -125,6 +125,7 @@ module ts {
|
|||
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
|
||||
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
|
||||
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
|
||||
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." },
|
||||
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
|
||||
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
|
||||
|
|
|
@ -491,6 +491,10 @@
|
|||
"category": "Error",
|
||||
"code": 1162
|
||||
},
|
||||
"'yield' expression must be contained_within a generator declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1163
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
|
|
|
@ -909,11 +909,35 @@ module ts {
|
|||
//
|
||||
// Getting this all correct is tricky and requires careful reading of the grammar to
|
||||
// understand when these values should be changed versus when they should be inherited.
|
||||
var strictModeContext = false;
|
||||
var disallowInContext = false;
|
||||
var contextFlags: ParserContextFlags = 0;
|
||||
|
||||
function setContextFlag(val: Boolean, flag: ParserContextFlags) {
|
||||
if (val) {
|
||||
contextFlags |= flag;
|
||||
}
|
||||
else {
|
||||
contextFlags &= ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
function setStrictModeContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.StrictMode);
|
||||
}
|
||||
|
||||
function setDisallowInContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.DisallowIn);
|
||||
}
|
||||
|
||||
function setYieldContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.Yield);
|
||||
}
|
||||
|
||||
function setGeneratorParameterContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.GeneratorParameter);
|
||||
}
|
||||
|
||||
function allowInAnd<T>(func: () => T): T {
|
||||
if (disallowInContext) {
|
||||
if (contextFlags & ParserContextFlags.DisallowIn) {
|
||||
setDisallowInContext(false);
|
||||
var result = func();
|
||||
setDisallowInContext(true);
|
||||
|
@ -925,7 +949,7 @@ module ts {
|
|||
}
|
||||
|
||||
function disallowInAnd<T>(func: () => T): T {
|
||||
if (disallowInContext) {
|
||||
if (contextFlags & ParserContextFlags.DisallowIn) {
|
||||
// no need to do anything special if 'in' is already disallowed.
|
||||
return func();
|
||||
}
|
||||
|
@ -936,8 +960,44 @@ module ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
function setDisallowInContext(val: boolean) {
|
||||
disallowInContext = val;
|
||||
function doInYieldContext<T>(func: () => T): T {
|
||||
if (contextFlags & ParserContextFlags.Yield) {
|
||||
// no need to do anything special if we're already in the [Yield] context.
|
||||
return func();
|
||||
}
|
||||
|
||||
setYieldContext(true);
|
||||
var result = func();
|
||||
setYieldContext(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
function doOutsideOfYieldContext<T>(func: () => T): T {
|
||||
if (contextFlags & ParserContextFlags.Yield) {
|
||||
setYieldContext(false);
|
||||
var result = func();
|
||||
setYieldContext(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
// no need to do anything special if we're not in the [Yield] context.
|
||||
return func();
|
||||
}
|
||||
|
||||
function inYieldContext() {
|
||||
return (contextFlags & ParserContextFlags.Yield) !== 0;
|
||||
}
|
||||
|
||||
function inStrictModeContext() {
|
||||
return (contextFlags & ParserContextFlags.StrictMode) !== 0;
|
||||
}
|
||||
|
||||
function inGeneratorParameterContext() {
|
||||
return (contextFlags & ParserContextFlags.GeneratorParameter) !== 0;
|
||||
}
|
||||
|
||||
function inDisallowInContext() {
|
||||
return (contextFlags & ParserContextFlags.DisallowIn) !== 0;
|
||||
}
|
||||
|
||||
function getLineStarts(): number[] {
|
||||
|
@ -1065,7 +1125,17 @@ module ts {
|
|||
}
|
||||
|
||||
function isIdentifier(): boolean {
|
||||
return token === SyntaxKind.Identifier || (strictModeContext ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord);
|
||||
if (token === SyntaxKind.Identifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is
|
||||
// considered a keyword and is not an identifier.
|
||||
if (token === SyntaxKind.YieldKeyword && inYieldContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return inStrictModeContext() ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord;
|
||||
}
|
||||
|
||||
function parseExpected(t: SyntaxKind): boolean {
|
||||
|
@ -1122,12 +1192,8 @@ module ts {
|
|||
function finishNode<T extends Node>(node: T): T {
|
||||
node.end = scanner.getStartPos();
|
||||
|
||||
if (strictModeContext) {
|
||||
node.flags |= NodeFlags.ParsedInStrictModeContext;
|
||||
}
|
||||
|
||||
if (disallowInContext) {
|
||||
node.flags |= NodeFlags.ParsedInDisallowInContext
|
||||
if (contextFlags) {
|
||||
node.parserContextFlags = contextFlags;
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@ -1190,7 +1256,7 @@ module ts {
|
|||
function parseAnyContextualModifier(): boolean {
|
||||
return isModifier(token) && tryParse(() => {
|
||||
nextToken();
|
||||
return token === SyntaxKind.OpenBracketToken || isPropertyName();
|
||||
return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isPropertyName();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1210,8 +1276,9 @@ module ts {
|
|||
case ParsingContext.ClassMembers:
|
||||
return lookAhead(isClassMemberStart);
|
||||
case ParsingContext.EnumMembers:
|
||||
case ParsingContext.ObjectLiteralMembers:
|
||||
return isPropertyName();
|
||||
case ParsingContext.ObjectLiteralMembers:
|
||||
return token === SyntaxKind.AsteriskToken || isPropertyName();
|
||||
case ParsingContext.BaseTypeReferences:
|
||||
return isIdentifier() && ((token !== SyntaxKind.ExtendsKeyword && token !== SyntaxKind.ImplementsKeyword) || !lookAhead(() => (nextToken(), isIdentifier())));
|
||||
case ParsingContext.VariableDeclarations:
|
||||
|
@ -1315,16 +1382,16 @@ module ts {
|
|||
parsingContext |= 1 << kind;
|
||||
var result = <NodeArray<T>>[];
|
||||
result.pos = getNodePos();
|
||||
var savedStrictModeContext = strictModeContext;
|
||||
var savedStrictModeContext = inStrictModeContext();
|
||||
while (!isListTerminator(kind)) {
|
||||
if (isListElement(kind, /* inErrorRecovery */ false)) {
|
||||
var element = parseElement();
|
||||
result.push(element);
|
||||
// test elements only if we are not already in strict mode
|
||||
if (!strictModeContext && checkForStrictMode) {
|
||||
if (!inStrictModeContext() && checkForStrictMode) {
|
||||
if (isPrologueDirective(element)) {
|
||||
if (isUseStrictPrologueDirective(element)) {
|
||||
strictModeContext = true;
|
||||
setStrictModeContext(true);
|
||||
checkForStrictMode = false;
|
||||
}
|
||||
}
|
||||
|
@ -1341,7 +1408,7 @@ module ts {
|
|||
nextToken();
|
||||
}
|
||||
}
|
||||
strictModeContext = savedStrictModeContext;
|
||||
setStrictModeContext(savedStrictModeContext);
|
||||
result.end = getNodeEnd();
|
||||
parsingContext = saveParsingContext;
|
||||
return result;
|
||||
|
@ -1403,12 +1470,13 @@ module ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
function parseBracketedList<T extends Node>(kind: ParsingContext, parseElement: () => T, startToken: SyntaxKind, endToken: SyntaxKind): NodeArray<T> {
|
||||
if (parseExpected(startToken)) {
|
||||
function parseBracketedList<T extends Node>(kind: ParsingContext, parseElement: () => T, open: SyntaxKind, close: SyntaxKind): NodeArray<T> {
|
||||
if (parseExpected(open)) {
|
||||
var result = parseDelimitedList(kind, parseElement);
|
||||
parseExpected(endToken);
|
||||
parseExpected(close);
|
||||
return result;
|
||||
}
|
||||
|
||||
return createMissingList<T>();
|
||||
}
|
||||
|
||||
|
@ -1580,7 +1648,15 @@ module ts {
|
|||
if (parseOptional(SyntaxKind.DotDotDotToken)) {
|
||||
node.flags |= NodeFlags.Rest;
|
||||
}
|
||||
node.name = parseIdentifier();
|
||||
|
||||
// SingleNameBinding[Yield,GeneratorParameter] : See 13.2.3
|
||||
// [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt
|
||||
// [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt
|
||||
|
||||
node.name = inGeneratorParameterContext()
|
||||
? doInYieldContext(parseIdentifier)
|
||||
: parseIdentifier();
|
||||
|
||||
if (node.name.kind === SyntaxKind.Missing && node.flags === 0 && isModifier(token)) {
|
||||
// in cases like
|
||||
// 'use strict'
|
||||
|
@ -1597,7 +1673,9 @@ module ts {
|
|||
node.flags |= NodeFlags.QuestionMark;
|
||||
}
|
||||
node.type = parseParameterType();
|
||||
node.initializer = parseInitializer(/*inParameter*/ true);
|
||||
node.initializer = inGeneratorParameterContext()
|
||||
? doOutsideOfYieldContext(parseParameterInitializer)
|
||||
: parseParameterInitializer();
|
||||
|
||||
// Do not check for initializers in an ambient context for parameters. This is not
|
||||
// a grammar error because the grammar allows arbitrary call signatures in
|
||||
|
@ -1610,18 +1688,28 @@ module ts {
|
|||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean): ParsedSignature {
|
||||
function parseParameterInitializer() {
|
||||
return parseInitializer(/*inParameter*/ true);
|
||||
}
|
||||
|
||||
function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean, yieldAndGeneratorParameterContext: boolean): ParsedSignature {
|
||||
var signature = <ParsedSignature>{};
|
||||
fillSignature(kind, returnToken, returnTokenRequired, signature);
|
||||
fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature);
|
||||
return signature;
|
||||
}
|
||||
|
||||
function fillSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean, signature: ParsedSignature): void {
|
||||
function fillSignature(
|
||||
kind: SyntaxKind,
|
||||
returnToken: SyntaxKind,
|
||||
returnTokenRequired: boolean,
|
||||
yieldAndGeneratorParameterContext: boolean,
|
||||
signature: ParsedSignature): void {
|
||||
|
||||
if (kind === SyntaxKind.ConstructSignature) {
|
||||
parseExpected(SyntaxKind.NewKeyword);
|
||||
}
|
||||
signature.typeParameters = parseTypeParameters();
|
||||
signature.parameters = parseParameterList(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
|
||||
signature.parameters = parseParameterList(yieldAndGeneratorParameterContext);
|
||||
|
||||
if (returnTokenRequired) {
|
||||
parseExpected(returnToken);
|
||||
|
@ -1632,15 +1720,47 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
// Because we use this for index signatures as well, we sometimes use
|
||||
// parentheses, and sometimes use brackets.
|
||||
function parseParameterList(startDelimiter: SyntaxKind, endDelimiter: SyntaxKind) {
|
||||
return parseBracketedList(ParsingContext.Parameters, parseParameter, startDelimiter, endDelimiter);
|
||||
// Note: after careful analysis of the grammar, it does not appear to be possible to
|
||||
// have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling
|
||||
// this FormalParameters production either always sets both to true, or always sets
|
||||
// both to false. As such we only have a single parameter to represent both.
|
||||
function parseParameterList(yieldAndGeneratorParameterContext: boolean) {
|
||||
// FormalParameters[Yield,GeneratorParameter] :
|
||||
// ...
|
||||
//
|
||||
// FormalParameter[Yield,GeneratorParameter] :
|
||||
// BindingElement[?Yield, ?GeneratorParameter]
|
||||
//
|
||||
// BindingElement[Yield, GeneratorParameter ] : See 13.2.3
|
||||
// SingleNameBinding[?Yield, ?GeneratorParameter]
|
||||
// [+GeneratorParameter]BindingPattern[?Yield, GeneratorParameter]Initializer[In]opt
|
||||
// [~GeneratorParameter]BindingPattern[?Yield]Initializer[In, ?Yield]opt
|
||||
//
|
||||
// SingleNameBinding[Yield, GeneratorParameter] : See 13.2.3
|
||||
// [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt
|
||||
// [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt
|
||||
if (parseExpected(SyntaxKind.OpenParenToken)) {
|
||||
var savedYieldContext = inYieldContext();
|
||||
var savedGeneratorParameterContext = inGeneratorParameterContext();
|
||||
|
||||
setYieldContext(yieldAndGeneratorParameterContext);
|
||||
setGeneratorParameterContext(yieldAndGeneratorParameterContext);
|
||||
|
||||
var result = parseDelimitedList(ParsingContext.Parameters, parseParameter);
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
|
||||
setYieldContext(savedYieldContext);
|
||||
setGeneratorParameterContext(savedGeneratorParameterContext);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return createMissingList<ParameterDeclaration>();
|
||||
}
|
||||
|
||||
function parseSignatureMember(kind: SyntaxKind, returnToken: SyntaxKind): SignatureDeclaration {
|
||||
var node = <SignatureDeclaration>createNode(kind);
|
||||
fillSignature(kind, returnToken, /* returnTokenRequired */ false, node);
|
||||
fillSignature(kind, returnToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, node);
|
||||
parseSemicolon();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
@ -1648,7 +1768,7 @@ module ts {
|
|||
function parseIndexSignatureMember(fullStart: number, modifiers: ModifiersArray): SignatureDeclaration {
|
||||
var node = <SignatureDeclaration>createNode(SyntaxKind.IndexSignature, fullStart);
|
||||
setModifiers(node, modifiers);
|
||||
node.parameters = parseParameterList(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
|
||||
node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
|
||||
node.type = parseTypeAnnotation();
|
||||
parseSemicolon();
|
||||
return finishNode(node)
|
||||
|
@ -1666,7 +1786,11 @@ module ts {
|
|||
var method = <MethodDeclaration>createNode(SyntaxKind.Method, fullStart);
|
||||
method.name = name;
|
||||
method.flags = flags;
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, method);
|
||||
|
||||
// Method signatues don't exist in expression contexts. So they have neither
|
||||
// [Yield] nor [GeneratorParameter]
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, method);
|
||||
|
||||
parseSemicolon();
|
||||
return finishNode(method);
|
||||
}
|
||||
|
@ -1749,7 +1873,7 @@ module ts {
|
|||
function parseFunctionType(typeKind: SyntaxKind): SignatureDeclaration {
|
||||
var node = <SignatureDeclaration>createNode(typeKind);
|
||||
fillSignature(typeKind === SyntaxKind.FunctionType ? SyntaxKind.CallSignature : SyntaxKind.ConstructSignature,
|
||||
SyntaxKind.EqualsGreaterThanToken, /* returnTokenRequired */ true, node);
|
||||
SyntaxKind.EqualsGreaterThanToken, /* returnTokenRequired */ true, /*yieldAndGeneratorParameterContext:*/ false, node);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -1869,6 +1993,23 @@ 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.
|
||||
var savedYieldContext = inYieldContext();
|
||||
var savedGeneratorParameterContext = inGeneratorParameterContext();
|
||||
|
||||
setYieldContext(false);
|
||||
setGeneratorParameterContext(false);
|
||||
|
||||
var result = parseTypeWorker();
|
||||
|
||||
setYieldContext(savedYieldContext);
|
||||
setGeneratorParameterContext(savedGeneratorParameterContext);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseTypeWorker(): TypeNode {
|
||||
if (isStartOfFunctionType()) {
|
||||
return parseFunctionType(SyntaxKind.FunctionType);
|
||||
}
|
||||
|
@ -1913,6 +2054,10 @@ module ts {
|
|||
case SyntaxKind.MinusMinusToken:
|
||||
case SyntaxKind.LessThanToken:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.YieldKeyword:
|
||||
// Yield always starts an expression. Either it is an identifier (in which case
|
||||
// it is definitely an expression). Or it's a keyword (either because we're in
|
||||
// a generator, or in strict mode (or both)) and it started a yield expression.
|
||||
return true;
|
||||
default:
|
||||
return isIdentifier();
|
||||
|
@ -1961,18 +2106,22 @@ module ts {
|
|||
}
|
||||
|
||||
function parseAssignmentExpression(): Expression {
|
||||
// Augmented by TypeScript:
|
||||
//
|
||||
// AssignmentExpression[in]:
|
||||
// 1) ConditionalExpression[in]
|
||||
// 2) LeftHandSideExpression = AssignmentExpression[in]
|
||||
// 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[in]
|
||||
// 4) ArrowFunctionExpression <-- added by TypeScript
|
||||
// AssignmentExpression[in,yield]:
|
||||
// 1) ConditionalExpression[?in,?yield]
|
||||
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
||||
// 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield]
|
||||
// 4) ArrowFunctionExpression[?in,?yield]
|
||||
// 5) [+Yield] YieldExpression[?In]
|
||||
//
|
||||
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
|
||||
// (i.e. they're both BinaryExpressions with an assignment operator in it).
|
||||
|
||||
// First, check if we have an arrow function (production '4') that starts with a parenthesized
|
||||
// First, do the simple check if we have a YieldExpression (production '5').
|
||||
if (isYieldExpression()) {
|
||||
return parseYieldExpression();
|
||||
}
|
||||
|
||||
// Then, check if we have an arrow function (production '4') that starts with a parenthesized
|
||||
// parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
||||
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
||||
// with AssignmentExpression if we see one.
|
||||
|
@ -2005,6 +2154,68 @@ module ts {
|
|||
return expr;
|
||||
}
|
||||
|
||||
function isYieldExpression(): boolean {
|
||||
if (token === SyntaxKind.YieldKeyword) {
|
||||
// If we have a 'yield' keyword, and htis is a context where yield expressions are
|
||||
// allowed, then definitely parse out a yield expression.
|
||||
if (inYieldContext()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (inStrictModeContext()) {
|
||||
// If we're in strict mode, then 'yield' is a keyword, could only ever start
|
||||
// a yield expression.
|
||||
return true;
|
||||
}
|
||||
|
||||
// We're in a context where 'yield expr' is not allowed. However, if we can
|
||||
// definitely tell that the user was trying to parse a 'yield expr' and not
|
||||
// just a normal expr that start with a 'yield' identifier, then parse out
|
||||
// a 'yield expr'. We can then report an error later that they are only
|
||||
// allowed in generator expressions.
|
||||
//
|
||||
// for example, if we see 'yield(foo)', then we'll have to treat that as an
|
||||
// invocation expression of something called 'yield'. However, if we have
|
||||
// 'yield foo' then that is not legal as a normal expression, so we can
|
||||
// definitely recognize this as a yield expression.
|
||||
//
|
||||
// for now we just check if the next token is an identifier. More heuristics
|
||||
// can be added here later as necessary. We just need to make sure that we
|
||||
// don't accidently consume something legal.
|
||||
return lookAhead(() => {
|
||||
nextToken();
|
||||
return !scanner.hasPrecedingLineBreak() && isIdentifier();
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseYieldExpression(): YieldExpression {
|
||||
var node = <YieldExpression>createNode(SyntaxKind.YieldExpression);
|
||||
|
||||
// YieldExpression[In] :
|
||||
// yield
|
||||
// yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield]
|
||||
// yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield]
|
||||
nextToken();
|
||||
|
||||
if (!scanner.hasPrecedingLineBreak() &&
|
||||
(token === SyntaxKind.AsteriskToken || isStartOfExpression())) {
|
||||
if (parseOptional(SyntaxKind.AsteriskToken)) {
|
||||
node.flags = NodeFlags.YieldStar;
|
||||
}
|
||||
|
||||
node.expression = parseAssignmentExpression();
|
||||
return finishNode(node);
|
||||
}
|
||||
else {
|
||||
// if the next token is not on the same line as yield. or we don't have an '*' or
|
||||
// the start of an expressin, then this is just a simple "yield" expression.
|
||||
return finishNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
function parseSimpleArrowFunctionExpression(identifier: Identifier): Expression {
|
||||
Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
||||
parseExpected(SyntaxKind.EqualsGreaterThanToken);
|
||||
|
@ -2034,7 +2245,8 @@ module ts {
|
|||
var pos = getNodePos();
|
||||
|
||||
if (triState === Tristate.True) {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
// Arrow function are never generators.
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false);
|
||||
|
||||
// If we have an arrow, then try to parse the body.
|
||||
// Even if not, try to parse if we have an opening brace, just in case we're in an error state.
|
||||
|
@ -2137,7 +2349,8 @@ module ts {
|
|||
|
||||
function tryParseSignatureIfArrowOrBraceFollows(): ParsedSignature {
|
||||
return tryParse(() => {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
// Arrow functions are never generators.
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false);
|
||||
|
||||
// Parsing a signature isn't enough.
|
||||
// Parenthesized arrow signatures often look like other valid expressions.
|
||||
|
@ -2159,7 +2372,7 @@ module ts {
|
|||
var body: Node;
|
||||
|
||||
if (token === SyntaxKind.OpenBraceToken) {
|
||||
body = parseFunctionBlock(/* ignoreMissingOpenBrace */ false);
|
||||
body = parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ false);
|
||||
}
|
||||
else if (isStatement(/* inErrorRecovery */ true) && !isStartOfExpressionStatement() && token !== SyntaxKind.FunctionKeyword) {
|
||||
// Check if we got a plain statement (i.e. no expression-statements, no functions expressions/declarations)
|
||||
|
@ -2176,7 +2389,7 @@ module ts {
|
|||
// up preemptively closing the containing construct.
|
||||
//
|
||||
// Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error.
|
||||
body = parseFunctionBlock(/* ignoreMissingOpenBrace */ true);
|
||||
body = parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ true);
|
||||
}
|
||||
else {
|
||||
body = parseAssignmentExpression();
|
||||
|
@ -2205,7 +2418,7 @@ module ts {
|
|||
while (true) {
|
||||
reScanGreaterToken();
|
||||
var precedence = getOperatorPrecedence();
|
||||
if (precedence && precedence > minPrecedence && (!disallowInContext || token !== SyntaxKind.InKeyword)) {
|
||||
if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== SyntaxKind.InKeyword)) {
|
||||
var operator = token;
|
||||
nextToken();
|
||||
expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence));
|
||||
|
@ -2518,15 +2731,20 @@ module ts {
|
|||
|
||||
function parsePropertyAssignment(): Declaration {
|
||||
var nodePos = scanner.getStartPos();
|
||||
var isGenerator = parseOptional(SyntaxKind.AsteriskToken);
|
||||
var tokenIsIdentifier = isIdentifier();
|
||||
var nameToken = token;
|
||||
var propertyName = parsePropertyName();
|
||||
var node: Declaration;
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
if (isGenerator || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
node = <PropertyDeclaration>createNode(SyntaxKind.PropertyAssignment, nodePos);
|
||||
node.name = propertyName;
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
var body = parseFunctionBlock(/* ignoreMissingOpenBrace */ false);
|
||||
if (isGenerator) {
|
||||
node.flags |= NodeFlags.Generator;
|
||||
}
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator);
|
||||
|
||||
var body = parseFunctionBlock(isGenerator, /* ignoreMissingOpenBrace */ false);
|
||||
// do not propagate property name as name for function expression
|
||||
// for scenarios like
|
||||
// var x = 1;
|
||||
|
@ -2583,16 +2801,31 @@ module ts {
|
|||
}
|
||||
|
||||
function parseFunctionExpression(): FunctionExpression {
|
||||
// GeneratorExpression :
|
||||
// function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] }
|
||||
// FunctionExpression:
|
||||
// function BindingIdentifieropt(FormalParameters) { FunctionBody }
|
||||
|
||||
var pos = getNodePos();
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
var name = isIdentifier() ? parseIdentifier() : undefined;
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
var body = parseFunctionBlock(/* ignoreMissingOpenBrace */ false);
|
||||
return makeFunctionExpression(SyntaxKind.FunctionExpression, pos, name, sig, body);
|
||||
var isGenerator = parseOptional(SyntaxKind.AsteriskToken);
|
||||
var name = isGenerator ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier();
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator);
|
||||
|
||||
var body = parseFunctionBlock(/*allowYield:*/ isGenerator, /* ignoreMissingOpenBrace */ false);
|
||||
return makeFunctionExpression(SyntaxKind.FunctionExpression, pos, name, sig, body, isGenerator ? NodeFlags.Generator : undefined);
|
||||
}
|
||||
|
||||
function makeFunctionExpression(kind: SyntaxKind, pos: number, name: Identifier, sig: ParsedSignature, body: Node): FunctionExpression {
|
||||
function parseOptionalIdentifier() {
|
||||
return isIdentifier() ? parseIdentifier() : undefined;
|
||||
}
|
||||
|
||||
function makeFunctionExpression(kind: SyntaxKind, pos: number, name: Identifier, sig: ParsedSignature, body: Node, flags?: NodeFlags): FunctionExpression {
|
||||
var node = <FunctionExpression>createNode(kind, pos);
|
||||
if (flags) {
|
||||
node.flags = flags;
|
||||
}
|
||||
|
||||
node.name = name;
|
||||
node.typeParameters = sig.typeParameters;
|
||||
node.parameters = sig.parameters;
|
||||
|
@ -2625,10 +2858,15 @@ module ts {
|
|||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseFunctionBlock(ignoreMissingOpenBrace: boolean): Block {
|
||||
function parseFunctionBlock(allowYield: boolean, ignoreMissingOpenBrace: boolean): Block {
|
||||
var savedYieldContext = inYieldContext();
|
||||
setYieldContext(allowYield);
|
||||
|
||||
var block = parseBlock(ignoreMissingOpenBrace, /*checkForStrictMode*/ true);
|
||||
block.kind = SyntaxKind.FunctionBlock;
|
||||
|
||||
setYieldContext(savedYieldContext);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -2993,9 +3231,9 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
function parseFunctionBlockOrSemicolon(): Block {
|
||||
function parseFunctionBlockOrSemicolon(isGenerator: boolean): Block {
|
||||
if (token === SyntaxKind.OpenBraceToken) {
|
||||
return parseFunctionBlock(/* ignoreMissingOpenBrace */ false);
|
||||
return parseFunctionBlock(isGenerator, /* ignoreMissingOpenBrace */ false);
|
||||
}
|
||||
|
||||
if (canParseSemicolon()) {
|
||||
|
@ -3054,9 +3292,14 @@ module ts {
|
|||
var node = <FunctionLikeDeclaration>createNode(SyntaxKind.FunctionDeclaration, fullStart);
|
||||
setModifiers(node, modifiers);
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
var isGenerator = parseOptional(SyntaxKind.AsteriskToken);
|
||||
if (isGenerator) {
|
||||
node.flags |= NodeFlags.Generator;
|
||||
}
|
||||
|
||||
node.name = parseIdentifier();
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon();
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator, node);
|
||||
node.body = parseFunctionBlockOrSemicolon(isGenerator);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -3064,29 +3307,34 @@ module ts {
|
|||
var node = <ConstructorDeclaration>createNode(SyntaxKind.Constructor, pos);
|
||||
setModifiers(node, modifiers);
|
||||
parseExpected(SyntaxKind.ConstructorKeyword);
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon();
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon(/*isGenerator:*/ false);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parsePropertyMemberDeclaration(fullStart: number, modifiers: ModifiersArray): Declaration {
|
||||
var name = parsePropertyName();
|
||||
var flags = modifiers ? modifiers.flags : 0;
|
||||
var isGenerator = parseOptional(SyntaxKind.AsteriskToken);
|
||||
if (isGenerator) {
|
||||
flags |= NodeFlags.Generator;
|
||||
}
|
||||
|
||||
var name = parsePropertyName();
|
||||
if (parseOptional(SyntaxKind.QuestionToken)) {
|
||||
// Note: this is not legal as per the grammar. But we allow it in the parser and
|
||||
// report an error in the grammar checker.
|
||||
flags |= NodeFlags.QuestionMark;
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
if (isGenerator || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
var method = <MethodDeclaration>createNode(SyntaxKind.Method, fullStart);
|
||||
setModifiers(method, modifiers);
|
||||
if (flags) {
|
||||
method.flags = flags;
|
||||
}
|
||||
method.name = name;
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, method);
|
||||
method.body = parseFunctionBlockOrSemicolon();
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator, method);
|
||||
method.body = parseFunctionBlockOrSemicolon(isGenerator);
|
||||
return finishNode(method);
|
||||
}
|
||||
else {
|
||||
|
@ -3107,8 +3355,8 @@ module ts {
|
|||
var node = <MethodDeclaration>createNode(kind, fullStart);
|
||||
setModifiers(node, modifiers);
|
||||
node.name = parsePropertyName();
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon();
|
||||
fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon(/*isGenerator:*/ false);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -3121,6 +3369,10 @@ module ts {
|
|||
nextToken();
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.AsteriskToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try to get the first property-like token following all modifiers.
|
||||
// This can either be an identifier or the 'get' or 'set' keywords.
|
||||
if (isPropertyName()) {
|
||||
|
@ -3197,7 +3449,7 @@ module ts {
|
|||
if (token === SyntaxKind.ConstructorKeyword) {
|
||||
return parseConstructorDeclaration(fullStart, modifiers);
|
||||
}
|
||||
if (token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral) {
|
||||
if (token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || token === SyntaxKind.AsteriskToken) {
|
||||
return parsePropertyMemberDeclaration(fullStart, modifiers);
|
||||
}
|
||||
if (token === SyntaxKind.OpenBracketToken) {
|
||||
|
@ -3216,12 +3468,26 @@ module ts {
|
|||
node.typeParameters = parseTypeParameters();
|
||||
|
||||
// TODO(jfreeman): Parse arbitrary sequence of heritage clauses and error for order and duplicates
|
||||
node.baseType = parseOptional(SyntaxKind.ExtendsKeyword) ? parseTypeReference() : undefined;
|
||||
|
||||
// ClassTail[Yield,GeneratorParameter] : See 14.5
|
||||
// [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt }
|
||||
// [+GeneratorParameter] ClassHeritageopt { ClassBodyopt }
|
||||
|
||||
node.baseType = inGeneratorParameterContext()
|
||||
? doOutsideOfYieldContext(parseClassBaseType)
|
||||
: parseClassBaseType();
|
||||
|
||||
if (parseOptional(SyntaxKind.ImplementsKeyword)) {
|
||||
node.implementedTypes = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference);
|
||||
}
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
node.members = parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassMemberDeclaration);
|
||||
// ClassTail[Yield,GeneratorParameter] : See 14.5
|
||||
// [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt }
|
||||
// [+GeneratorParameter] ClassHeritageopt { ClassBodyopt }
|
||||
|
||||
node.members = inGeneratorParameterContext()
|
||||
? doOutsideOfYieldContext(parseClassMembers)
|
||||
: parseClassMembers();
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
else {
|
||||
|
@ -3230,6 +3496,14 @@ module ts {
|
|||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseClassMembers() {
|
||||
return parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassMemberDeclaration);
|
||||
}
|
||||
|
||||
function parseClassBaseType(): TypeReferenceNode {
|
||||
return parseOptional(SyntaxKind.ExtendsKeyword) ? parseTypeReference() : undefined;
|
||||
}
|
||||
|
||||
function parseInterfaceDeclaration(fullStart: number, modifiers: ModifiersArray): InterfaceDeclaration {
|
||||
var node = <InterfaceDeclaration>createNode(SyntaxKind.InterfaceDeclaration, fullStart);
|
||||
setModifiers(node, modifiers);
|
||||
|
@ -3668,7 +3942,6 @@ module ts {
|
|||
return checkCallOrNewExpression(<NewExpression>node);
|
||||
|
||||
case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(<EnumDeclaration>node);
|
||||
case SyntaxKind.Parameter: return checkParameter(<ParameterDeclaration>node);
|
||||
case SyntaxKind.BinaryExpression: return checkBinaryExpression(<BinaryExpression>node);
|
||||
case SyntaxKind.CatchBlock: return checkCatchBlock(<CatchBlock>node);
|
||||
case SyntaxKind.ClassDeclaration: return checkClassDeclaration(<ClassDeclaration>node);
|
||||
|
@ -3687,6 +3960,7 @@ module ts {
|
|||
case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(<ModuleDeclaration>node);
|
||||
case SyntaxKind.ObjectLiteral: return checkObjectLiteral(<ObjectLiteral>node);
|
||||
case SyntaxKind.NumericLiteral: return checkNumericLiteral(<LiteralExpression>node);
|
||||
case SyntaxKind.Parameter: return checkParameter(<ParameterDeclaration>node);
|
||||
case SyntaxKind.PostfixOperator: return checkPostfixOperator(<UnaryExpression>node);
|
||||
case SyntaxKind.PrefixOperator: return checkPrefixOperator(<UnaryExpression>node);
|
||||
case SyntaxKind.Property: return checkProperty(<PropertyDeclaration>node);
|
||||
|
@ -3703,6 +3977,7 @@ module ts {
|
|||
case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(<VariableDeclaration>node);
|
||||
case SyntaxKind.VariableStatement: return checkVariableStatement(<VariableStatement>node);
|
||||
case SyntaxKind.WithStatement: return checkWithStatement(<WithStatement>node);
|
||||
case SyntaxKind.YieldExpression: return checkYieldExpression(<YieldExpression>node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3764,7 +4039,7 @@ module ts {
|
|||
}
|
||||
|
||||
function checkBinaryExpression(node: BinaryExpression) {
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
|
||||
if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) {
|
||||
if (isEvalOrArgumentsIdentifier(node.left)) {
|
||||
// ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an
|
||||
|
@ -3916,7 +4191,7 @@ module ts {
|
|||
var colonStart = skipTrivia(sourceText, node.variable.end);
|
||||
return grammarErrorAtPos(colonStart, ":".length, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation);
|
||||
}
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.variable)) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.variable)) {
|
||||
// It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the
|
||||
// Catch production is eval or arguments
|
||||
return reportInvalidUseInStrictMode(node.variable);
|
||||
|
@ -4036,7 +4311,7 @@ module ts {
|
|||
}
|
||||
|
||||
function checkFunctionName(name: Node) {
|
||||
if (name && name.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(name)) {
|
||||
if (name && name.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(name)) {
|
||||
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
||||
// Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1)
|
||||
return reportInvalidUseInStrictMode(<Identifier>name);
|
||||
|
@ -4157,7 +4432,7 @@ module ts {
|
|||
var GetAccessor = 2;
|
||||
var SetAccesor = 4;
|
||||
var GetOrSetAccessor = GetAccessor | SetAccesor;
|
||||
var inStrictMode = (node.flags & NodeFlags.ParsedInStrictModeContext) !== 0;
|
||||
var inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0;
|
||||
|
||||
for (var i = 0, n = node.properties.length; i < n; i++) {
|
||||
var prop = node.properties[i];
|
||||
|
@ -4221,7 +4496,7 @@ module ts {
|
|||
|
||||
function checkNumericLiteral(node: LiteralExpression): boolean {
|
||||
if (node.flags & NodeFlags.OctalLiteral) {
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
|
||||
}
|
||||
else if (languageVersion >= ScriptTarget.ES5) {
|
||||
|
@ -4365,7 +4640,7 @@ module ts {
|
|||
// or if its FunctionBody is strict code(11.1.5).
|
||||
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
||||
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
return reportInvalidUseInStrictMode(node.name);
|
||||
}
|
||||
}
|
||||
|
@ -4424,13 +4699,13 @@ module ts {
|
|||
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an
|
||||
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
|
||||
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator.
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.operand)) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.operand)) {
|
||||
return reportInvalidUseInStrictMode(<Identifier>node.operand);
|
||||
}
|
||||
}
|
||||
|
||||
function checkPrefixOperator(node: UnaryExpression) {
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
|
||||
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an
|
||||
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
|
||||
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator
|
||||
|
@ -4615,7 +4890,7 @@ module ts {
|
|||
if (!inAmbientContext && !node.initializer && isConst(node)) {
|
||||
return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized);
|
||||
}
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
// It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code
|
||||
// and its Identifier is eval or arguments
|
||||
return reportInvalidUseInStrictMode(node.name);
|
||||
|
@ -4677,12 +4952,18 @@ module ts {
|
|||
}
|
||||
|
||||
function checkWithStatement(node: WithStatement): boolean {
|
||||
if (node.flags & NodeFlags.ParsedInStrictModeContext) {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
|
||||
// Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such
|
||||
// a context is an
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
|
||||
}
|
||||
}
|
||||
|
||||
function checkYieldExpression(node: YieldExpression): boolean {
|
||||
if (!(node.parserContextFlags & ParserContextFlags.Yield)) {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program {
|
||||
|
|
|
@ -183,6 +183,7 @@ module ts {
|
|||
ConditionalExpression,
|
||||
TemplateExpression,
|
||||
TemplateSpan,
|
||||
YieldExpression,
|
||||
OmittedExpression,
|
||||
// Element
|
||||
Block,
|
||||
|
@ -269,22 +270,30 @@ module ts {
|
|||
DeclarationFile = 0x00000400, // Node is a .d.ts file
|
||||
Let = 0x00000800, // Variable declaration
|
||||
Const = 0x00001000, // Variable declaration
|
||||
|
||||
// Set if this node was parsed in strict mode. Used for grammar error checks, as well as
|
||||
// checking if the node can be reused in incremental settings.
|
||||
ParsedInStrictModeContext = 0x00002000,
|
||||
ParsedInDisallowInContext = 0x00004000,
|
||||
|
||||
OctalLiteral = 0x00008000,
|
||||
OctalLiteral = 0x00002000,
|
||||
Generator = 0x00004000,
|
||||
YieldStar = 0x00008000,
|
||||
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static,
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
BlockScoped = Let | Const
|
||||
}
|
||||
|
||||
export const enum ParserContextFlags {
|
||||
// Set if this node was parsed in strict mode. Used for grammar error checks, as well as
|
||||
// checking if the node can be reused in incremental settings.
|
||||
StrictMode = 1 << 0,
|
||||
DisallowIn = 1 << 1,
|
||||
Yield = 1 << 2,
|
||||
GeneratorParameter = 1 << 3,
|
||||
}
|
||||
|
||||
export interface Node extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
// Specific context the parser was in when this node was created. Normally undefined.
|
||||
// Only set when the parser was in some interesting context (like async/yield).
|
||||
parserContextFlags?: ParserContextFlags;
|
||||
id?: number; // Unique id (used to look up NodeLinks)
|
||||
parent?: Node; // Parent node (initialized by binding)
|
||||
symbol?: Symbol; // Symbol declared by node (initialized by binding)
|
||||
|
@ -431,6 +440,10 @@ module ts {
|
|||
operator: SyntaxKind;
|
||||
operand: Expression;
|
||||
}
|
||||
|
||||
export interface YieldExpression extends Expression {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface BinaryExpression extends Expression {
|
||||
left: Expression;
|
||||
|
|
|
@ -1,29 +1,24 @@
|
|||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export const enum ParserContextFlags {
|
||||
StrictMode = 1 << 0,
|
||||
DisallowIn = 1 << 1,
|
||||
Yield = 1 << 2,
|
||||
GeneratorParameter = 1 << 3,
|
||||
|
||||
Mask = 0xF
|
||||
}
|
||||
|
||||
export enum SyntaxNodeConstants {
|
||||
None = 0,
|
||||
|
||||
// Masks that we use to place information about a node into a single int. The first bit tells
|
||||
// us if we've computed the data for a node.
|
||||
//
|
||||
// The second bit tells us if the node is incrementally reusable if it does not
|
||||
// containe any skipped tokens, zero width tokens, regex tokens in it ("/", "/=" or "/.../"),
|
||||
// and contains no tokens that were parser generated.
|
||||
//
|
||||
// The next bit lets us know if the nodes was parsed in a strict context or node. A node can
|
||||
// only be used by the incremental parser if it is parsed in the same strict context as before.
|
||||
// last masks off the part of the int
|
||||
//
|
||||
// The first four bit of the flags are used to store parser context flags.
|
||||
// The width of the node is stored in the remainder of the int. This allows us up to 128MB
|
||||
// for a node by using all 27 bits. However, in the common case, we'll use less than 27 bits
|
||||
// for the width. Thus, the info will be stored in a single int in chakra.
|
||||
DataComputed = 0x00000001, // 0000 0000 0000 0000 0000 0000 0000 0001
|
||||
IncrementallyUnusableMask = 0x00000002, // 0000 0000 0000 0000 0000 0000 0000 0010
|
||||
ParsedInStrictModeContext = 0x00000004, // 0000 0000 0000 0000 0000 0000 0000 0100
|
||||
ParsedInDisallowInContext = 0x00000008, // 0000 0000 0000 0000 0000 0000 0000 1000
|
||||
ParsedInYieldContext = 0x00000010, // 0000 0000 0000 0000 0000 0000 0001 0000
|
||||
ParsedInGeneratorParameterContext = 0x00000020, // 0000 0000 0000 0000 0000 0000 0010 0000
|
||||
FullWidthShift = 1 << 6, // 1111 1111 1111 1111 1111 1111 1100 0000
|
||||
DataComputed = 1 << 4, // 0000 0000 0000 0000 0000 0000 0001 0000
|
||||
IncrementallyUnusableMask = 1 << 5, // 0000 0000 0000 0000 0000 0000 0010 0000
|
||||
FullWidthShift = 1 << 6, // 1111 1111 1111 1111 1111 1111 1100 0000
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -17,40 +17,29 @@ module TypeScript {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
export function parsedInStrictModeContext(node: ISyntaxNode): boolean {
|
||||
export function parserContextFlags(node: ISyntaxNode): ParserContextFlags {
|
||||
var info = node.__data;
|
||||
if (info === undefined) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (info & SyntaxNodeConstants.ParsedInStrictModeContext) !== 0;
|
||||
return info & ParserContextFlags.Mask;
|
||||
}
|
||||
|
||||
export function parsedInStrictModeContext(node: ISyntaxNode): boolean {
|
||||
return (parserContextFlags(node) & ParserContextFlags.StrictMode) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInDisallowInContext(node: ISyntaxNode): boolean {
|
||||
var info = node.__data;
|
||||
if (info === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (info & SyntaxNodeConstants.ParsedInDisallowInContext) !== 0;
|
||||
return (parserContextFlags(node) & ParserContextFlags.DisallowIn) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInYieldContext(node: ISyntaxNode): boolean {
|
||||
var info = node.__data;
|
||||
if (info === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (info & SyntaxNodeConstants.ParsedInYieldContext) !== 0;
|
||||
return (parserContextFlags(node) & ParserContextFlags.Yield) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInGeneratorParameterContext(node: ISyntaxNode): boolean {
|
||||
var info = node.__data;
|
||||
if (info === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (info & SyntaxNodeConstants.ParsedInGeneratorParameterContext) !== 0;
|
||||
return (parserContextFlags(node) & ParserContextFlags.GeneratorParameter) !== 0;
|
||||
}
|
||||
|
||||
export function previousToken(token: ISyntaxToken): ISyntaxToken {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts(2,8): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts (1 errors) ====
|
||||
class C {
|
||||
[e] = 1
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(2,7): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(2,8): error TS1109: Expression expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts (3 errors) ====
|
||||
class C {
|
||||
[e]();
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
|
@ -0,0 +1,15 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(2,7): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(2,10): error TS1005: '=>' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts (3 errors) ====
|
||||
class C {
|
||||
[e]() { }
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~
|
||||
!!! error TS1005: '=>' expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts(1,11): error TS1022: An index signature parameter must have a type annotation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts (1 errors) ====
|
||||
var v: { [e]: number };
|
||||
~
|
||||
!!! error TS1022: An index signature parameter must have a type annotation.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts(1,13): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts (1 errors) ====
|
||||
var v: { [e](): number };
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts(1,32): error TS1022: An index signature parameter must have a type annotation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts (1 errors) ====
|
||||
var v: { [e: number]: string; [e]: number };
|
||||
~
|
||||
!!! error TS1022: An index signature parameter must have a type annotation.
|
|
@ -0,0 +1,18 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,3): error TS1132: Enum member expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,3): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,4): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts (4 errors) ====
|
||||
enum E {
|
||||
[e] = 1
|
||||
~
|
||||
!!! error TS1132: Enum member expected.
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,15): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,22): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,26): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,16): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts (4 errors) ====
|
||||
var v = { set [e](v) { } }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts(1,13): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts (1 errors) ====
|
||||
var v: { [e]?(): number };
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts(1,13): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts (1 errors) ====
|
||||
var v: { [e]? };
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
|
@ -0,0 +1,13 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,11): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,15): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,12): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts (3 errors) ====
|
||||
var v = { [e] };
|
||||
~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
|
@ -0,0 +1,19 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,11): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,14): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,16): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,18): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,12): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts (5 errors) ====
|
||||
var v = { [e]: 1 };
|
||||
~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,11): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,17): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,21): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,12): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts (4 errors) ====
|
||||
var v = { [e]() { } };
|
||||
~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,15): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,21): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,25): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,16): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts (4 errors) ====
|
||||
var v = { get [e]() { } };
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
|
@ -0,0 +1,19 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,18): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,28): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,32): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,18): error TS2304: Cannot find name 'get'.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,23): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts (5 errors) ====
|
||||
var v = { public get [e]() { } };
|
||||
~~~
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'get'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
|
@ -0,0 +1,28 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,11): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,14): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,16): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,26): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,30): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,12): error TS2304: Cannot find name 'e'.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,20): error TS2304: Cannot find name 'e'.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,24): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts (8 errors) ====
|
||||
var v = { [e]: 1, [e + e]: 2 };
|
||||
~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts(2,5): error TS1022: An index signature parameter must have a type annotation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts (1 errors) ====
|
||||
class C {
|
||||
[e]
|
||||
~
|
||||
!!! error TS1022: An index signature parameter must have a type annotation.
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts(2,12): error TS1022: An index signature parameter must have a type annotation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts (1 errors) ====
|
||||
class C {
|
||||
public [e]
|
||||
~
|
||||
!!! error TS1022: An index signature parameter must have a type annotation.
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts(2,5): error TS1022: An index signature parameter must have a type annotation.
|
||||
tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts(2,9): error TS2304: Cannot find name 'Type'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts (2 errors) ====
|
||||
class C {
|
||||
[e]: Type
|
||||
~
|
||||
!!! error TS1022: An index signature parameter must have a type annotation.
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'Type'.
|
||||
}
|
8
tests/baselines/reference/FunctionDeclaration10_es6.js
Normal file
8
tests/baselines/reference/FunctionDeclaration10_es6.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [FunctionDeclaration10_es6.ts]
|
||||
function * foo(a = yield => yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration10_es6.js]
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = function (yield) { return yield; }; }
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts ===
|
||||
function * foo(a = yield => yield) {
|
||||
>foo : (a?: (yield: any) => any) => void
|
||||
>a : (yield: any) => any
|
||||
>yield => yield : (yield: any) => any
|
||||
>yield : any
|
||||
>yield : any
|
||||
}
|
7
tests/baselines/reference/FunctionDeclaration11_es6.js
Normal file
7
tests/baselines/reference/FunctionDeclaration11_es6.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [FunctionDeclaration11_es6.ts]
|
||||
function * yield() {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration11_es6.js]
|
||||
function yield() {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts ===
|
||||
function * yield() {
|
||||
>yield : () => void
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,20): error TS1005: '(' expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,25): error TS1005: '=' expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,28): error TS1005: '=>' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts (3 errors) ====
|
||||
var v = function * yield() { }
|
||||
~~~~~
|
||||
!!! error TS1005: '(' expected.
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~
|
||||
!!! error TS1005: '=>' expected.
|
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (1 errors) ====
|
||||
function * foo() {
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v: yield;
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
|
12
tests/baselines/reference/FunctionDeclaration13_es6.js
Normal file
12
tests/baselines/reference/FunctionDeclaration13_es6.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
//// [FunctionDeclaration13_es6.ts]
|
||||
function * foo() {
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v: yield;
|
||||
}
|
||||
|
||||
|
||||
//// [FunctionDeclaration13_es6.js]
|
||||
function foo() {
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v;
|
||||
}
|
7
tests/baselines/reference/FunctionDeclaration1_es6.js
Normal file
7
tests/baselines/reference/FunctionDeclaration1_es6.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [FunctionDeclaration1_es6.ts]
|
||||
function * foo() {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration1_es6.js]
|
||||
function foo() {
|
||||
}
|
4
tests/baselines/reference/FunctionDeclaration1_es6.types
Normal file
4
tests/baselines/reference/FunctionDeclaration1_es6.types
Normal file
|
@ -0,0 +1,4 @@
|
|||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts ===
|
||||
function * foo() {
|
||||
>foo : () => void
|
||||
}
|
7
tests/baselines/reference/FunctionDeclaration2_es6.js
Normal file
7
tests/baselines/reference/FunctionDeclaration2_es6.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [FunctionDeclaration2_es6.ts]
|
||||
function f(yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration2_es6.js]
|
||||
function f(yield) {
|
||||
}
|
5
tests/baselines/reference/FunctionDeclaration2_es6.types
Normal file
5
tests/baselines/reference/FunctionDeclaration2_es6.types
Normal file
|
@ -0,0 +1,5 @@
|
|||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration2_es6.ts ===
|
||||
function f(yield) {
|
||||
>f : (yield: any) => void
|
||||
>yield : any
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'yield' cannot be referenced in its initializer.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts (1 errors) ====
|
||||
function f(yield = yield) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'yield' cannot be referenced in its initializer.
|
||||
}
|
8
tests/baselines/reference/FunctionDeclaration3_es6.js
Normal file
8
tests/baselines/reference/FunctionDeclaration3_es6.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [FunctionDeclaration3_es6.ts]
|
||||
function f(yield = yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration3_es6.js]
|
||||
function f(yield) {
|
||||
if (yield === void 0) { yield = yield; }
|
||||
}
|
7
tests/baselines/reference/FunctionDeclaration4_es6.js
Normal file
7
tests/baselines/reference/FunctionDeclaration4_es6.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [FunctionDeclaration4_es6.ts]
|
||||
function yield() {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration4_es6.js]
|
||||
function yield() {
|
||||
}
|
4
tests/baselines/reference/FunctionDeclaration4_es6.types
Normal file
4
tests/baselines/reference/FunctionDeclaration4_es6.types
Normal file
|
@ -0,0 +1,4 @@
|
|||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration4_es6.ts ===
|
||||
function yield() {
|
||||
>yield : () => void
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS1138: Parameter declaration expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,19): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts (4 errors) ====
|
||||
function*foo(yield) {
|
||||
~~~~~
|
||||
!!! error TS1138: Parameter declaration expected.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (1 errors) ====
|
||||
function*foo(a = yield) {
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
8
tests/baselines/reference/FunctionDeclaration6_es6.js
Normal file
8
tests/baselines/reference/FunctionDeclaration6_es6.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [FunctionDeclaration6_es6.ts]
|
||||
function*foo(a = yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration6_es6.js]
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = yield; }
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (1 errors) ====
|
||||
function*bar() {
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function*foo(a = yield) {
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
}
|
14
tests/baselines/reference/FunctionDeclaration7_es6.js
Normal file
14
tests/baselines/reference/FunctionDeclaration7_es6.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
//// [FunctionDeclaration7_es6.ts]
|
||||
function*bar() {
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function*foo(a = yield) {
|
||||
}
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration7_es6.js]
|
||||
function bar() {
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = yield; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,18): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,24): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (4 errors) ====
|
||||
var v = { [yield]: foo }
|
||||
~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
|
@ -0,0 +1,15 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,20): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ====
|
||||
function * foo() {
|
||||
var v = { [yield]: foo }
|
||||
~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
6
tests/baselines/reference/FunctionExpression1_es6.js
Normal file
6
tests/baselines/reference/FunctionExpression1_es6.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
//// [FunctionExpression1_es6.ts]
|
||||
var v = function * () { }
|
||||
|
||||
//// [FunctionExpression1_es6.js]
|
||||
var v = function () {
|
||||
};
|
5
tests/baselines/reference/FunctionExpression1_es6.types
Normal file
5
tests/baselines/reference/FunctionExpression1_es6.types
Normal file
|
@ -0,0 +1,5 @@
|
|||
=== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts ===
|
||||
var v = function * () { }
|
||||
>v : () => void
|
||||
>function * () { } : () => void
|
||||
|
6
tests/baselines/reference/FunctionExpression2_es6.js
Normal file
6
tests/baselines/reference/FunctionExpression2_es6.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
//// [FunctionExpression2_es6.ts]
|
||||
var v = function * foo() { }
|
||||
|
||||
//// [FunctionExpression2_es6.js]
|
||||
var v = function foo() {
|
||||
};
|
6
tests/baselines/reference/FunctionExpression2_es6.types
Normal file
6
tests/baselines/reference/FunctionExpression2_es6.types
Normal file
|
@ -0,0 +1,6 @@
|
|||
=== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts ===
|
||||
var v = function * foo() { }
|
||||
>v : () => void
|
||||
>function * foo() { } : () => void
|
||||
>foo : () => void
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
//// [FunctionPropertyAssignments1_es6.ts]
|
||||
var v = { *foo() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments1_es6.js]
|
||||
var v = { foo: function () {
|
||||
} };
|
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts ===
|
||||
var v = { *foo() { } }
|
||||
>v : { foo: () => void; }
|
||||
>{ *foo() { } } : { foo: () => void; }
|
||||
>foo : () => void
|
||||
>*foo() { } : () => void
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts(1,12): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts (1 errors) ====
|
||||
var v = { *() { } }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts(1,12): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts (1 errors) ====
|
||||
var v = { *{ } }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts(1,13): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts (1 errors) ====
|
||||
var v = { * }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,22): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,26): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (4 errors) ====
|
||||
var v = { *[foo()]() { } }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts(1,12): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts (1 errors) ====
|
||||
var v = { *<T>() { } }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
13
tests/baselines/reference/MemberFunctionDeclaration1_es6.js
Normal file
13
tests/baselines/reference/MemberFunctionDeclaration1_es6.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
//// [MemberFunctionDeclaration1_es6.ts]
|
||||
class C {
|
||||
*foo() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration1_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
*foo() { }
|
||||
>foo : () => void
|
||||
}
|
13
tests/baselines/reference/MemberFunctionDeclaration2_es6.js
Normal file
13
tests/baselines/reference/MemberFunctionDeclaration2_es6.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
//// [MemberFunctionDeclaration2_es6.ts]
|
||||
class C {
|
||||
public * foo() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration2_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
public * foo() { }
|
||||
>foo : () => void
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,5): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,10): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,13): error TS1005: '=>' expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (4 errors) ====
|
||||
class C {
|
||||
*[foo]() { }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~
|
||||
!!! error TS1005: '=>' expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts(2,5): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*() { }
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts(3,1): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*
|
||||
}
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
|
@ -0,0 +1,12 @@
|
|||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts(3,1): error TS1005: '(' expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts(2,5): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts (2 errors) ====
|
||||
class C {
|
||||
*foo
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
}
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
13
tests/baselines/reference/MemberFunctionDeclaration7_es6.js
Normal file
13
tests/baselines/reference/MemberFunctionDeclaration7_es6.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
//// [MemberFunctionDeclaration7_es6.ts]
|
||||
class C {
|
||||
*foo<T>() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration7_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
*foo<T>() { }
|
||||
>foo : <T>() => void
|
||||
>T : T
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,12): error TS1127: Invalid character.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,14): error TS1129: Statement expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,19): error TS1005: '(' expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(5,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(6,3): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(7,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,9): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,16): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts (8 errors) ====
|
||||
class C {
|
||||
foo() {
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a) # * bar;
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
~
|
||||
!!! error TS1129: Statement expected.
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
return bar;
|
||||
~~~~~~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
10
tests/baselines/reference/TemplateExpression1.errors.txt
Normal file
10
tests/baselines/reference/TemplateExpression1.errors.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,19): error TS1158: Invalid template literal; expected '}'
|
||||
tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,17): error TS2304: Cannot find name 'a'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/TemplateExpression1.ts (2 errors) ====
|
||||
var v = `foo ${ a
|
||||
|
||||
!!! error TS1158: Invalid template literal; expected '}'
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
11
tests/baselines/reference/YieldExpression10_es6.js
Normal file
11
tests/baselines/reference/YieldExpression10_es6.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [YieldExpression10_es6.ts]
|
||||
var v = { * foo() {
|
||||
yield(foo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [YieldExpression10_es6.js]
|
||||
var v = { foo: function () {
|
||||
;
|
||||
} };
|
11
tests/baselines/reference/YieldExpression10_es6.types
Normal file
11
tests/baselines/reference/YieldExpression10_es6.types
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts ===
|
||||
var v = { * foo() {
|
||||
>v : { foo: () => void; }
|
||||
>{ * foo() { yield(foo); }} : { foo: () => void; }
|
||||
>foo : () => void
|
||||
>* foo() { yield(foo); } : () => void
|
||||
|
||||
yield(foo);
|
||||
}
|
||||
}
|
||||
|
16
tests/baselines/reference/YieldExpression11_es6.js
Normal file
16
tests/baselines/reference/YieldExpression11_es6.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
//// [YieldExpression11_es6.ts]
|
||||
class C {
|
||||
*foo() {
|
||||
yield(foo);
|
||||
}
|
||||
}
|
||||
|
||||
//// [YieldExpression11_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
;
|
||||
};
|
||||
return C;
|
||||
})();
|
10
tests/baselines/reference/YieldExpression11_es6.types
Normal file
10
tests/baselines/reference/YieldExpression11_es6.types
Normal file
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
*foo() {
|
||||
>foo : () => void
|
||||
|
||||
yield(foo);
|
||||
}
|
||||
}
|
11
tests/baselines/reference/YieldExpression12_es6.errors.txt
Normal file
11
tests/baselines/reference/YieldExpression12_es6.errors.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ====
|
||||
class C {
|
||||
constructor() {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
}
|
||||
}
|
7
tests/baselines/reference/YieldExpression13_es6.js
Normal file
7
tests/baselines/reference/YieldExpression13_es6.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [YieldExpression13_es6.ts]
|
||||
function* foo() { yield }
|
||||
|
||||
//// [YieldExpression13_es6.js]
|
||||
function foo() {
|
||||
;
|
||||
}
|
4
tests/baselines/reference/YieldExpression13_es6.types
Normal file
4
tests/baselines/reference/YieldExpression13_es6.types
Normal file
|
@ -0,0 +1,4 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts ===
|
||||
function* foo() { yield }
|
||||
>foo : () => void
|
||||
|
11
tests/baselines/reference/YieldExpression14_es6.errors.txt
Normal file
11
tests/baselines/reference/YieldExpression14_es6.errors.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ====
|
||||
class C {
|
||||
foo() {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ====
|
||||
var v = () => {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
}
|
11
tests/baselines/reference/YieldExpression16_es6.errors.txt
Normal file
11
tests/baselines/reference/YieldExpression16_es6.errors.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
function bar() {
|
||||
yield foo;
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
}
|
||||
}
|
10
tests/baselines/reference/YieldExpression17_es6.errors.txt
Normal file
10
tests/baselines/reference/YieldExpression17_es6.errors.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (2 errors) ====
|
||||
var v = { get foo() { yield foo; } }
|
||||
~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
|
@ -0,0 +1,8 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ====
|
||||
"use strict";
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
17
tests/baselines/reference/YieldExpression19_es6.js
Normal file
17
tests/baselines/reference/YieldExpression19_es6.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
//// [YieldExpression19_es6.ts]
|
||||
function*foo() {
|
||||
function bar() {
|
||||
function* quux() {
|
||||
yield(foo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [YieldExpression19_es6.js]
|
||||
function foo() {
|
||||
function bar() {
|
||||
function quux() {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
14
tests/baselines/reference/YieldExpression19_es6.types
Normal file
14
tests/baselines/reference/YieldExpression19_es6.types
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts ===
|
||||
function*foo() {
|
||||
>foo : () => void
|
||||
|
||||
function bar() {
|
||||
>bar : () => void
|
||||
|
||||
function* quux() {
|
||||
>quux : () => void
|
||||
|
||||
yield(foo);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts (1 errors) ====
|
||||
yield;
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
5
tests/baselines/reference/YieldExpression1_es6.js
Normal file
5
tests/baselines/reference/YieldExpression1_es6.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
//// [YieldExpression1_es6.ts]
|
||||
yield;
|
||||
|
||||
//// [YieldExpression1_es6.js]
|
||||
yield;
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ====
|
||||
yield foo;
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
11
tests/baselines/reference/YieldExpression3_es6.js
Normal file
11
tests/baselines/reference/YieldExpression3_es6.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [YieldExpression3_es6.ts]
|
||||
function* foo() {
|
||||
yield
|
||||
yield
|
||||
}
|
||||
|
||||
//// [YieldExpression3_es6.js]
|
||||
function foo() {
|
||||
;
|
||||
;
|
||||
}
|
7
tests/baselines/reference/YieldExpression3_es6.types
Normal file
7
tests/baselines/reference/YieldExpression3_es6.types
Normal file
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts ===
|
||||
function* foo() {
|
||||
>foo : () => void
|
||||
|
||||
yield
|
||||
yield
|
||||
}
|
11
tests/baselines/reference/YieldExpression4_es6.js
Normal file
11
tests/baselines/reference/YieldExpression4_es6.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [YieldExpression4_es6.ts]
|
||||
function* foo() {
|
||||
yield;
|
||||
yield;
|
||||
}
|
||||
|
||||
//// [YieldExpression4_es6.js]
|
||||
function foo() {
|
||||
;
|
||||
;
|
||||
}
|
7
tests/baselines/reference/YieldExpression4_es6.types
Normal file
7
tests/baselines/reference/YieldExpression4_es6.types
Normal file
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts ===
|
||||
function* foo() {
|
||||
>foo : () => void
|
||||
|
||||
yield;
|
||||
yield;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts(3,1): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
yield*
|
||||
}
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
9
tests/baselines/reference/YieldExpression6_es6.js
Normal file
9
tests/baselines/reference/YieldExpression6_es6.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [YieldExpression6_es6.ts]
|
||||
function* foo() {
|
||||
yield*foo
|
||||
}
|
||||
|
||||
//// [YieldExpression6_es6.js]
|
||||
function foo() {
|
||||
;
|
||||
}
|
6
tests/baselines/reference/YieldExpression6_es6.types
Normal file
6
tests/baselines/reference/YieldExpression6_es6.types
Normal file
|
@ -0,0 +1,6 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts ===
|
||||
function* foo() {
|
||||
>foo : () => void
|
||||
|
||||
yield*foo
|
||||
}
|
9
tests/baselines/reference/YieldExpression7_es6.js
Normal file
9
tests/baselines/reference/YieldExpression7_es6.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [YieldExpression7_es6.ts]
|
||||
function* foo() {
|
||||
yield foo
|
||||
}
|
||||
|
||||
//// [YieldExpression7_es6.js]
|
||||
function foo() {
|
||||
;
|
||||
}
|
6
tests/baselines/reference/YieldExpression7_es6.types
Normal file
6
tests/baselines/reference/YieldExpression7_es6.types
Normal file
|
@ -0,0 +1,6 @@
|
|||
=== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts ===
|
||||
function* foo() {
|
||||
>foo : () => void
|
||||
|
||||
yield foo
|
||||
}
|
10
tests/baselines/reference/YieldExpression8_es6.errors.txt
Normal file
10
tests/baselines/reference/YieldExpression8_es6.errors.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (1 errors) ====
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
function* foo() {
|
||||
yield(foo);
|
||||
}
|
11
tests/baselines/reference/YieldExpression8_es6.js
Normal file
11
tests/baselines/reference/YieldExpression8_es6.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [YieldExpression8_es6.ts]
|
||||
yield(foo);
|
||||
function* foo() {
|
||||
yield(foo);
|
||||
}
|
||||
|
||||
//// [YieldExpression8_es6.js]
|
||||
yield(foo);
|
||||
function foo() {
|
||||
;
|
||||
}
|
9
tests/baselines/reference/YieldExpression9_es6.js
Normal file
9
tests/baselines/reference/YieldExpression9_es6.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [YieldExpression9_es6.ts]
|
||||
var v = function*() {
|
||||
yield(foo);
|
||||
}
|
||||
|
||||
//// [YieldExpression9_es6.js]
|
||||
var v = function () {
|
||||
;
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue