Use the entire indexer node for grammar error reporting.

This commit is contained in:
Cyrus Najmabadi
2014-11-18 18:20:41 -08:00
parent 08f0672b03
commit 34bb53f54c
13 changed files with 106 additions and 32 deletions

View File

@@ -0,0 +1,8 @@
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors3.ts(1,5): error TS1003: Identifier expected.
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors3.ts (1 errors) ====
(...) => 105;
~
!!! error TS1003: Identifier expected.

View File

@@ -0,0 +1,49 @@
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(1,14): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(2,15): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(3,21): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(4,7): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(4,39): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(17,10): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(19,13): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(6,5): error TS2304: Cannot find name 'foo'.
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts (8 errors) ====
false ? (arg?: number = 0) => 47 : null;
~~~
!!! error TS1015: Parameter cannot have question mark and initializer.
false ? ((arg?: number = 0) => 57) : null;
~~~
!!! error TS1015: Parameter cannot have question mark and initializer.
false ? null : (arg?: number = 0) => 67;
~~~
!!! error TS1015: Parameter cannot have question mark and initializer.
((arg?:number = 1) => 0) + '' + ((arg?:number = 2) => 106);
~~~
!!! error TS1015: Parameter cannot have question mark and initializer.
~~~
!!! error TS1015: Parameter cannot have question mark and initializer.
foo(
~~~
!!! error TS2304: Cannot find name 'foo'.
(a) => 110,
((a) => 111),
(a) => {
return 112;
},
(a? ) => 113,
(a, b? ) => 114,
(a: number) => 115,
(a: number = 0) => 116,
(a = 0) => 117,
(a?: number = 0) => 118,
~
!!! error TS1015: Parameter cannot have question mark and initializer.
(...a: number[]) => 119,
(a, b? = 0, ...c: number[]) => 120,
~
!!! error TS1015: Parameter cannot have question mark and initializer.
(a) => (b) => (c) => 121,
false? (a) => 0 : (b) => 122
);

View File

@@ -388,7 +388,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -502,7 +502,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -633,7 +633,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -866,7 +866,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -980,7 +980,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -1111,7 +1111,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -1380,7 +1380,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -1484,7 +1484,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~

View File

@@ -10,7 +10,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021
~
!!! error TS1022: An index signature parameter must have a type annotation.
[x: string];
~~~~~~~~~~~
~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
}

View File

@@ -11,10 +11,10 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression
==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ====
interface Red {
[n:number]; // ok
~~~~~~~~~~
~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[s:string]; // ok
~~~~~~~~~~
~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
}

View File

@@ -3,5 +3,5 @@ tests/cases/compiler/indexWithoutParamType.ts(1,10): error TS1096: An index sign
==== tests/cases/compiler/indexWithoutParamType.ts (1 errors) ====
var y: { []; } // Error
~~
~~~
!!! error TS1096: An index signature must have exactly one parameter.

View File

@@ -130,7 +130,7 @@ tests/cases/compiler/intTypeCheck.ts(203,17): error TS2351: Cannot use 'new' wit
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~
@@ -171,7 +171,7 @@ tests/cases/compiler/intTypeCheck.ts(203,17): error TS2351: Cannot use 'new' wit
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~

View File

@@ -9,7 +9,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1
~
!!! error TS1022: An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
~~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
[p2: string, p3: number];
~~

View File

@@ -4,6 +4,6 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature9
==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature9.ts (1 errors) ====
interface I {
[]: number
~~
~~~~~~~~~~
!!! error TS1096: An index signature must have exactly one parameter.
}

View File

@@ -8,6 +8,6 @@ tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts(2,7)
~
!!! error TS2304: Cannot find name 'B'.
[];
~~
~~~
!!! error TS1096: An index signature must have exactly one parameter.
};

View File

@@ -0,0 +1 @@
(...) => 105;

View File

@@ -0,0 +1,22 @@
false ? (arg?: number = 0) => 47 : null;
false ? ((arg?: number = 0) => 57) : null;
false ? null : (arg?: number = 0) => 67;
((arg?:number = 1) => 0) + '' + ((arg?:number = 2) => 106);
foo(
(a) => 110,
((a) => 111),
(a) => {
return 112;
},
(a? ) => 113,
(a, b? ) => 114,
(a: number) => 115,
(a: number = 0) => 116,
(a = 0) => 117,
(a?: number = 0) => 118,
(...a: number[]) => 119,
(a, b? = 0, ...c: number[]) => 120,
(a) => (b) => (c) => 121,
false? (a) => 0 : (b) => 122
);