Correctly handle the character position at the EOF.

Fixes issue #1785.
This commit is contained in:
Kevin Atkinson 2012-02-08 17:45:02 -07:00
parent d808df893a
commit f9a63efb82
2 changed files with 12 additions and 1 deletions

View file

@ -43,7 +43,13 @@ impl reader for reader {
let next = str::char_range_at(*self.src, self.pos);
self.pos = next.next;
self.curr = next.ch;
} else { self.curr = -1 as char; }
} else {
if (self.curr != -1 as char) {
self.col += 1u;
self.chpos += 1u;
self.curr = -1 as char;
}
}
}
fn fatal(m: str) -> ! {
self.span_diagnostic.span_fatal(

View file

@ -76,6 +76,11 @@ fn main() {
let pat = #ast(pat){some(_)};
check_pp(pat, pprust::print_pat, "some(_)");
// issue #1785
let x = #ast{1};
let test1 = #ast{1+$(x)};
check_pp(test1, pprust::print_expr, "1 + 1");
}
fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) {