mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fix the error spans issue
This commit is contained in:
parent
c27379827b
commit
fad5650be6
@ -81,7 +81,7 @@ module ts {
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
var start = skipTrivia(file.text, node.pos);
|
||||
var start = node.kind === SyntaxKind.Missing ? node.pos : skipTrivia(file.text, node.pos);
|
||||
var length = node.end - start;
|
||||
|
||||
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
|
||||
@ -2876,10 +2876,11 @@ module ts {
|
||||
parseExpected(SyntaxKind.VarKeyword);
|
||||
node.declarations = parseVariableDeclarationList(flags, /*noIn*/false);
|
||||
parseSemicolon();
|
||||
finishNode(node);
|
||||
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
|
||||
grammarErrorOnNode(node, Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||
}
|
||||
return finishNode(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
function parseFunctionDeclaration(pos?: number, flags?: NodeFlags): FunctionDeclaration {
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
function =>
|
||||
~~
|
||||
!!! Identifier expected.
|
||||
|
||||
|
||||
!!! Function implementation is missing or not immediately following the declaration.
|
||||
@ -8,5 +8,5 @@
|
||||
!!! ',' expected.
|
||||
|
||||
!!! ')' expected.
|
||||
|
||||
|
||||
!!! Function implementation is missing or not immediately following the declaration.
|
||||
@ -1,4 +1,4 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration6.ts (1 errors) ====
|
||||
var
|
||||
|
||||
~~~
|
||||
!!! Variable declaration list cannot be empty.
|
||||
@ -1,4 +1,4 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration8.ts (1 errors) ====
|
||||
var ;
|
||||
|
||||
~~~~~
|
||||
!!! Variable declaration list cannot be empty.
|
||||
Loading…
x
Reference in New Issue
Block a user