aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <[email protected]>2011-01-27 15:50:19 -0500
committerRafael Ávila de Espíndola <[email protected]>2011-01-27 15:56:10 -0500
commit21208f23439acfae35e615abbe791b3011b950bc (patch)
tree4ea169e6cf1a9ac8a03528c376b838c031bb536c /src
parentFirst step for supporting "case (foo.bar(?zed))": Change the ast of (diff)
downloadrust-21208f23439acfae35e615abbe791b3011b950bc.tar.xz
rust-21208f23439acfae35e615abbe791b3011b950bc.zip
Handle paths correctly. This lets us handle one more test :-)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile1
-rw-r--r--src/comp/middle/resolve.rs20
-rw-r--r--src/test/run-pass/alt-path.rs15
3 files changed, 23 insertions, 13 deletions
diff --git a/src/Makefile b/src/Makefile
index 1cc5cecf..6d5da821 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -421,6 +421,7 @@ TEST_XFAILS_BOOT := $(TASK_XFAILS) \
TEST_XFAILS_RUSTC := $(filter-out \
$(addprefix test/run-pass/, \
+ alt-path.rs \
alt-pattern-simple.rs \
alt-tag.rs \
arith-0.rs \
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index 76dcc9dc..8010b2a5 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -381,21 +381,15 @@ fn fold_pat_tag(&env e, &span sp, ast.path p, vec[@ast.pat] args,
auto len = _vec.len[ast.ident](p.node.idents);
auto last_id = p.node.idents.(len - 1u);
auto new_def;
- 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: " + last_id);
- new_def = none[ast.variant_def];
- }
- }
+ auto index = new_def_hash[def_wrap]();
+ auto d = find_final_def(e, index, sp, p.node.idents, none[ast.def_id]);
+ alt (unwrap_def(d)) {
+ case (ast.def_variant(?did, ?vid)) {
+ new_def = some[ast.variant_def](tup(did, vid));
}
- case (none[def]) {
+ case (_) {
+ e.sess.span_err(sp, "not a tag variant: " + last_id);
new_def = none[ast.variant_def];
- e.sess.span_err(sp, "unresolved name: " + last_id);
}
}
diff --git a/src/test/run-pass/alt-path.rs b/src/test/run-pass/alt-path.rs
new file mode 100644
index 00000000..45faa700
--- /dev/null
+++ b/src/test/run-pass/alt-path.rs
@@ -0,0 +1,15 @@
+import m1.foo;
+mod m1 {
+ tag foo {
+ foo1;
+ foo2;
+ }
+}
+fn bar(foo x) {
+ alt(x) {
+ case (m1.foo1) {
+ }
+ }
+}
+fn main(vec[str] args) {
+}