mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Pass 0-based indexes to CompilerError
This commit is contained in:
@@ -180,7 +180,7 @@
|
||||
loc = _arg.loc, token = _arg.token;
|
||||
message = "unexpected " + token;
|
||||
first_line = loc.first_line, first_column = loc.first_column, last_line = loc.last_line, last_column = loc.last_column;
|
||||
throw new CompilerError(message, first_line + 1, first_column + 1, last_line + 1, last_column + 1);
|
||||
throw new CompilerError(message, first_line, first_column, last_line, last_column);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
|
||||
CompilerError.prototype.prettyMessage = function(fileName, code) {
|
||||
var errorLength, errorLine, marker, message;
|
||||
message = "" + fileName + ":" + this.startLine + ":" + this.startColumn + ": error: " + this.message;
|
||||
message = "" + fileName + ":" + (this.startLine + 1) + ":" + (this.startColumn + 1) + ": error: " + this.message;
|
||||
if (this.startLine === this.endLine) {
|
||||
errorLine = code.split('\n')[this.startLine - 1];
|
||||
errorLine = code.split('\n')[this.startLine];
|
||||
errorLength = this.endColumn - this.startColumn + 1;
|
||||
marker = (repeat(' ', this.startColumn - 1)) + (repeat('^', errorLength));
|
||||
marker = (repeat(' ', this.startColumn)) + (repeat('^', errorLength));
|
||||
message += "\n" + errorLine + "\n" + marker;
|
||||
} else {
|
||||
void 0;
|
||||
|
||||
@@ -788,7 +788,7 @@
|
||||
};
|
||||
|
||||
Lexer.prototype.error = function(message) {
|
||||
throw new CompilerError(message, this.chunkLine + 1, this.chunkColumn + 1);
|
||||
throw new CompilerError(message, this.chunkLine, this.chunkColumn);
|
||||
};
|
||||
|
||||
return Lexer;
|
||||
|
||||
Reference in New Issue
Block a user