Skip to content

Commit 6868739

Browse files
committed
handle cases where we have a node with width 0 when reporting grammar errors
1 parent 85ead1e commit 6868739

File tree

3 files changed

+858
-1
lines changed

3 files changed

+858
-1
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ module ts {
654654
// applying some stricter checks on that node.
655655
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
656656
var span = getErrorSpanForNode(node);
657-
var start = skipTrivia(file.text, span.pos);
657+
var start = span.end > span.pos ? skipTrivia(file.text, span.pos) : span.pos;
658658
var length = span.end - start;
659659

660660
file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));

0 commit comments

Comments
 (0)