diff options
| author | Rafael Ávila de Espíndola <[email protected]> | 2011-01-27 15:25:07 -0500 |
|---|---|---|
| committer | Rafael Ávila de Espíndola <[email protected]> | 2011-01-27 15:27:56 -0500 |
| commit | 5066937f108cf364cb31bdd517bf3d984ecec73d (patch) | |
| tree | d04e5f00286ef90700ee39a71932c8e255664cbc /src/comp/middle/resolve.rs | |
| parent | Fix documentation: aliases may not be used in loop constructs. (diff) | |
| download | rust-5066937f108cf364cb31bdd517bf3d984ecec73d.tar.xz rust-5066937f108cf364cb31bdd517bf3d984ecec73d.zip | |
First step for supporting "case (foo.bar(?zed))": Change the ast of
pat_tag to hold a path.
Diffstat (limited to 'src/comp/middle/resolve.rs')
| -rw-r--r-- | src/comp/middle/resolve.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 724664b3..76dcc9dc 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -375,29 +375,31 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] { } } -fn fold_pat_tag(&env e, &span sp, ident i, vec[@ast.pat] args, +fn fold_pat_tag(&env e, &span sp, ast.path p, vec[@ast.pat] args, option.t[ast.variant_def] old_def, ann a) -> @ast.pat { + auto len = _vec.len[ast.ident](p.node.idents); + auto last_id = p.node.idents.(len - 1u); auto new_def; - alt (lookup_name(e, i)) { + alt (lookup_name(e, last_id)) { case (some[def](?d)) { alt (d) { case (ast.def_variant(?did, ?vid)) { new_def = some[ast.variant_def](tup(did, vid)); } case (_) { - e.sess.span_err(sp, "not a tag variant: " + i); + e.sess.span_err(sp, "not a tag variant: " + last_id); new_def = none[ast.variant_def]; } } } case (none[def]) { new_def = none[ast.variant_def]; - e.sess.span_err(sp, "unresolved name: " + i); + e.sess.span_err(sp, "unresolved name: " + last_id); } } - ret @fold.respan[ast.pat_](sp, ast.pat_tag(i, args, new_def, a)); + ret @fold.respan[ast.pat_](sp, ast.pat_tag(p, args, new_def, a)); } // We received a path expression of the following form: |