about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Atkinson <kevina@cs.utah.edu>2012-02-08 17:45:02 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-02-14 19:37:33 -0800
commit3eef8d14197d5166286f6a4dbc4b604e52581618 (patch)
treeeda30cee331badb80286054cb37bc5378cc93130
parent379194753c3684f800540d26702453b487a3630c (diff)
downloadrust-3eef8d14197d5166286f6a4dbc4b604e52581618.tar.gz
rust-3eef8d14197d5166286f6a4dbc4b604e52581618.zip
Correctly handle the character position at the EOF.
Fixes issue #1785.
-rw-r--r--src/comp/syntax/parse/lexer.rs8
-rw-r--r--src/test/run-pass/qquote.rs5
2 files changed, 12 insertions, 1 deletions
diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs
index 300d0a66f1d..aa989cb0f61 100644
--- a/src/comp/syntax/parse/lexer.rs
+++ b/src/comp/syntax/parse/lexer.rs
@@ -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(
diff --git a/src/test/run-pass/qquote.rs b/src/test/run-pass/qquote.rs
index 50751a66081..ef10f03129b 100644
--- a/src/test/run-pass/qquote.rs
+++ b/src/test/run-pass/qquote.rs
@@ -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) {