Proper spans for empty type arg/param lists.

This commit is contained in:
Cyrus Najmabadi
2014-11-19 12:26:55 -08:00
parent 90cc44bb2f
commit e5e707709d
2 changed files with 6 additions and 6 deletions

View File

@@ -4093,7 +4093,7 @@ module ts {
function checkForAtLeastOneTypeArgument(typeArguments: NodeArray<TypeNode>) {
if (typeArguments && typeArguments.length === 0) {
var start = typeArguments.pos - "<".length;
var end = typeArguments.end + ">".length;
var end = skipTrivia(sourceText, typeArguments.end) + ">".length;
return grammarErrorAtPos(start, end - start, Diagnostics.Type_argument_list_cannot_be_empty);
}
}
@@ -4402,7 +4402,7 @@ module ts {
if (typeParameters && typeParameters.length === 0) {
var start = typeParameters.pos - "<".length;
var end = typeParameters.end + ">".length;
var end = skipTrivia(sourceText, typeParameters.end) + ">".length;
return grammarErrorAtPos(start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty);
}
}

View File

@@ -39,22 +39,22 @@ tests/cases/compiler/parserConstructorDeclaration12.ts(9,3): error TS2392: Multi
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor< >() { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor< > () { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor < >() { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor < > () { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.