diff --git a/src/comp/syntax/ext/qquote.rs b/src/comp/syntax/ext/qquote.rs index 8899ff64f57..1d5022d1903 100644 --- a/src/comp/syntax/ext/qquote.rs +++ b/src/comp/syntax/ext/qquote.rs @@ -184,11 +184,12 @@ fn finish 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; diff --git a/src/test/run-pass/qquote.rs b/src/test/run-pass/qquote.rs index ef10f03129b..46330d119b6 100644 --- a/src/test/run-pass/qquote.rs +++ b/src/test/run-pass/qquote.rs @@ -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(expr: T, f: fn(pprust::ps, T), expect: str) {