Stop showing a 'cyclic import' message for unresolved imports

This only happened for single-length import paths, because the import
was being looked up in its own scope.
This commit is contained in:
Marijn Haverbeke 2011-05-24 20:58:38 +02:00
parent bad05e20a3
commit fbc0e840e3
3 changed files with 13 additions and 9 deletions

View file

@ -323,10 +323,11 @@ fn resolve_import(&env e, &@ast::view_item it, &list[scope] sc) {
auto end_id = ids.(n_idents - 1u);
if (n_idents == 1u) {
auto next_sc = std::list::cdr(sc);
register(e, defid, it.span, end_id,
lookup_in_scope(e, sc, it.span, end_id, ns_value),
lookup_in_scope(e, sc, it.span, end_id, ns_type),
lookup_in_scope(e, sc, it.span, end_id, ns_module));
lookup_in_scope(e, next_sc, it.span, end_id, ns_value),
lookup_in_scope(e, next_sc, it.span, end_id, ns_type),
lookup_in_scope(e, next_sc, it.span, end_id, ns_module));
} else {
auto dcur = lookup_in_scope_strict(e, sc, it.span, ids.(0),
ns_module);
@ -724,7 +725,7 @@ fn lookup_import(&env e, def_id defid, namespace ns) -> option::t[def] {
ret lookup_import(e, defid, ns);
}
case (resolving(?sp)) {
e.sess.span_err(sp, "cyclic import or nonexistent module");
e.sess.span_err(sp, "cyclic import");
}
case (resolved(?val, ?typ, ?md)) {
ret alt (ns) { case (ns_value) { val }

View file

@ -1,7 +1,7 @@
// xfail-stage0
// error-pattern: nonexistent module
// error-pattern: unresolved import: vec
import vec;
fn main() {
auto foo = vec.len([]);
auto foo = vec::len([]);
}

View file

@ -1,7 +1,10 @@
// error-pattern:cyclic import
// error-pattern: cyclic import
import x;
import y::x;
mod y {
import x;
}
fn main() {
auto y = x;
}