Skip to content

Commit c273798

Browse files
committed
Add asserts for bounds on diagnostics
1 parent bf084f1 commit c273798

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compiler/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ module ts {
198198

199199
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
200200
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
201+
Debug.assert(start >= 0, "start must be non-negative, is " + start);
202+
Debug.assert(length >= 0, "length must be non-negative, is " + length);
203+
201204
var text = getLocaleSpecificMessage(message.key);
202205

203206
if (arguments.length > 4) {
@@ -252,6 +255,9 @@ module ts {
252255
}
253256

254257
export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic {
258+
Debug.assert(start >= 0, "start must be non-negative, is " + start);
259+
Debug.assert(length >= 0, "length must be non-negative, is " + length);
260+
255261
var code = diagnosticChain.code;
256262
var category = diagnosticChain.category;
257263
var messageText = "";

0 commit comments

Comments
 (0)