Skip to content

Commit 3eef8d1

Browse files
kevinanikomatsakis
authored andcommitted
Correctly handle the character position at the EOF.
Fixes issue #1785.
1 parent 3791947 commit 3eef8d1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/comp/syntax/parse/lexer.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ impl reader for reader {
4343
let next = str::char_range_at(*self.src, self.pos);
4444
self.pos = next.next;
4545
self.curr = next.ch;
46-
} else { self.curr = -1 as char; }
46+
} else {
47+
if (self.curr != -1 as char) {
48+
self.col += 1u;
49+
self.chpos += 1u;
50+
self.curr = -1 as char;
51+
}
52+
}
4753
}
4854
fn fatal(m: str) -> ! {
4955
self.span_diagnostic.span_fatal(

src/test/run-pass/qquote.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ fn main() {
7676

7777
let pat = #ast(pat){some(_)};
7878
check_pp(pat, pprust::print_pat, "some(_)");
79+
80+
// issue #1785
81+
let x = #ast{1};
82+
let test1 = #ast{1+$(x)};
83+
check_pp(test1, pprust::print_expr, "1 + 1");
7984
}
8085

8186
fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) {

0 commit comments

Comments
 (0)