Skip to content

Commit

Permalink
Correctly handle the character position at the EOF.
Browse files Browse the repository at this point in the history
Fixes issue #1785.
  • Loading branch information
kevina committed Feb 10, 2012
1 parent d808df8 commit f9a63ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/comp/syntax/parse/lexer.rs
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions src/test/run-pass/qquote.rs
Expand Up @@ -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) {
Expand Down

0 comments on commit f9a63ef

Please sign in to comment.