Move grammar check: deleteExpression

This commit is contained in:
Yui T 2014-12-12 12:59:00 -08:00
parent 00449d80a3
commit 90e1d4244f
2 changed files with 8 additions and 1 deletions

View file

@ -6555,6 +6555,13 @@ module ts {
}
function checkDeleteExpression(node: DeleteExpression): Type {
// Grammar checking
if (node.parserContextFlags & ParserContextFlags.StrictMode && node.expression.kind === SyntaxKind.Identifier) {
// When a delete operator occurs within strict mode code, a SyntaxError is thrown if its
// UnaryExpression is a direct reference to a variable, function argument, or function name
grammarErrorOnNode(node.expression, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode);
}
var operandType = checkExpression(node.expression);
return booleanType;
}

View file

@ -4640,7 +4640,7 @@ module ts {
//case SyntaxKind.ClassDeclaration: return checkClassDeclaration(<ClassDeclaration>node);
//case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(<ComputedPropertyName>node);
case SyntaxKind.Constructor: return checkConstructor(<ConstructorDeclaration>node);
case SyntaxKind.DeleteExpression: return checkDeleteExpression(<DeleteExpression> node);
//case SyntaxKind.DeleteExpression: return checkDeleteExpression(<DeleteExpression> node);
case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(<ElementAccessExpression>node);
case SyntaxKind.ExportAssignment: return checkExportAssignment(<ExportAssignment>node);
case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(<ExternalModuleReference>node);