Improve error messages
This commit is contained in:
parent
838e760729
commit
b8bcc700fa
|
@ -2733,6 +2733,7 @@ module ts {
|
|||
|
||||
function parsePropertyAssignment(): Declaration {
|
||||
var nodePos = scanner.getStartPos();
|
||||
var isTokenIdentifier = isIdentifier();
|
||||
var nameToken = token;
|
||||
var propertyName = parsePropertyName();
|
||||
var node: Declaration;
|
||||
|
@ -2757,7 +2758,7 @@ module ts {
|
|||
}
|
||||
|
||||
// Parse to check if it is short-hand property assignment or normal property assignment
|
||||
if (token !== SyntaxKind.ColonToken && nameToken === SyntaxKind.Identifier) {
|
||||
if ((token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBraceToken) && isTokenIdentifier) {
|
||||
node = <ShortHandPropertyDeclaration>createNode(SyntaxKind.ShorthandPropertyAssignment, nodePos);
|
||||
node.name = propertyName;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,14): error TS1005: ',' expected.
|
||||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,14): error TS1005: ':' expected.
|
||||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,16): error TS1128: Declaration or statement expected.
|
||||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,12): error TS2304: Cannot find name 'aa'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/incompleteObjectLiteral1.ts (3 errors) ====
|
||||
==== tests/cases/compiler/incompleteObjectLiteral1.ts (2 errors) ====
|
||||
var tt = { aa; }
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'aa'.
|
||||
var x = tt;
|
|
@ -7,18 +7,17 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
|||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(9,8): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(10,10): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(12,1): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,6): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,6): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,6): error TS1005: '=' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(18,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,6): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,6): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,6): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(20,17): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,7): error TS2304: Cannot find name 'b'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,5): error TS2300: Duplicate identifier 'a'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts (18 errors) ====
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts (17 errors) ====
|
||||
// errors
|
||||
var y = {
|
||||
"stringLiteral",
|
||||
|
@ -55,22 +54,20 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
|||
var x = {
|
||||
a.b,
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'b'.
|
||||
a["ss"],
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
a[1],
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
};
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
|
||||
var v = { class }; // error
|
||||
~
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorWithModule.ts(10,10): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorWithModule.ts(10,10): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorWithModule.ts(14,3): error TS2339: Property 'y' does not exist on type 'typeof m'.
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
|||
export var y = {
|
||||
m.x // error
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1005: ':' expected.
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,14): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,14): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,16): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,12): error TS2304: Cannot find name 'aa'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts (3 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts (2 errors) ====
|
||||
var tt = { aa; } // After this point, no useful parsing occurs in the entire file
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'aa'.
|
||||
|
||||
if (true) {
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,1): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,1): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,7): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(1,11): error TS2304: Cannot find name 'a'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts (3 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts (2 errors) ====
|
||||
var v = { a
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
return;
|
||||
~~~~~~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS1005: ':' expected.
|
Loading…
Reference in a new issue