Bug fix to accept $ in 0th pos, (ie #ast{$(x) + ...}).

Note: part from Niko Matsakis commit: rewrite assert to accept a $ in
0th pos.
This commit is contained in:
Kevin Atkinson 2012-02-10 17:27:35 -07:00
parent f9a63efb82
commit 48eda22835
2 changed files with 12 additions and 4 deletions

View File

@ -184,11 +184,12 @@ fn finish<T: qq_helper>
let sp = node.span();
let qcx = gather_anti_quotes(sp.lo, node);
let cx = qcx;
let prev = 0u;
for {lo: lo, _} in cx.gather {
assert lo > prev;
prev = lo;
// assert that the vector is sorted by position:
uint::range(1u, vec::len(cx.gather)) {|i|
assert cx.gather[i-1u].lo < cx.gather[i].lo;
}
let str2 = "";
enum state {active, skip(uint), blank};
let state = active;

View File

@ -81,6 +81,13 @@ fn main() {
let x = #ast{1};
let test1 = #ast{1+$(x)};
check_pp(test1, pprust::print_expr, "1 + 1");
let test2 = #ast{$(x)+1};
check_pp(test2, pprust::print_expr, "1 + 1");
let y = #ast{2};
let test3 = #ast{$(x) + $(y)};
check_pp(test3, pprust::print_expr, "1 + 2");
}
fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) {