diff options
| author | Graydon Hoare <[email protected]> | 2010-11-19 10:41:32 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-11-19 10:41:32 -0800 |
| commit | e94af48bc9d9b2b1bec39368614af14cdb3a296a (patch) | |
| tree | 7c6f66afefcf6f679a0b71613bcedd216dcbe2dd | |
| parent | rustboot: Don't use walk to traverse statements in type.ml; fixes redundant c... (diff) | |
| download | rust-e94af48bc9d9b2b1bec39368614af14cdb3a296a.tar.xz rust-e94af48bc9d9b2b1bec39368614af14cdb3a296a.zip | |
Work around Yet Another Typestate Lifecycle Bug in rustboot.
| -rw-r--r-- | src/comp/front/parser.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 2382efc1..63e43067 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -198,6 +198,17 @@ impure fn parse_arg(parser p) -> ast.arg { ret rec(mode=m, ty=t, ident=i, id=p.next_def_id()); } +// FIXME: workaround for a bug in the typestate walk of +// the while-graph; the while-loop header doesn't drop +// its slots, so "while (p.peek() ...) { ... }" leaks. + +fn peeking_at(parser p, token.token t) -> bool { + if (p.peek() == t) { + ret true; + } + ret false; +} + impure fn parse_seq[T](token.token bra, token.token ket, option.t[token.token] sep, @@ -207,7 +218,7 @@ impure fn parse_seq[T](token.token bra, auto lo = p.get_span(); expect(p, bra); let vec[T] v = vec(); - while (p.peek() != ket) { + while (!peeking_at(p, ket)) { alt(sep) { case (some[token.token](?t)) { if (first) { @@ -925,7 +936,7 @@ impure fn parse_mod_items(parser p, token.token term) -> ast._mod { let vec[@ast.item] items = vec(); let hashmap[ast.ident,uint] index = new_str_hash[uint](); let uint u = 0u; - while (p.peek() != term) { + while (!peeking_at(p, term)) { auto pair = parse_item(p); append[@ast.item](items, pair._1); index.insert(pair._0, u); |