Fix bug: globbed imports were importing everything visible from the other

module, not just everything exported.
This commit is contained in:
Paul Stansifer 2011-06-22 15:41:39 -07:00
parent adc18bb24a
commit b4c3b83f26
7 changed files with 38 additions and 11 deletions

View file

@ -940,9 +940,9 @@ fn lookup_in_local_mod(&env e, node_id node_id, &span sp, &ident id,
} }
} }
} }
// not local or explicitly imported; try globs:
ret lookup_glob_in_mod(e, info, sp, id, ns, dr); // not local or explicitly imported; try globs:
ret lookup_glob_in_mod(e, info, sp, id, ns, outside);
} }
fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, &ident id, fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, &ident id,

View file

@ -1,5 +1,6 @@
import std::bitv; import std::bitv;
import std::str;
import std::vec; import std::vec;
import std::vec::len; import std::vec::len;
import std::vec::grow; import std::vec::grow;
@ -12,6 +13,7 @@ import front::ast;
import front::ast::*; import front::ast::*;
import util::common; import util::common;
import util::common::span; import util::common::span;
import util::common::spanned;
import util::common::respan; import util::common::respan;
import util::common::log_block; import util::common::log_block;
import util::common::new_int_hash; import util::common::new_int_hash;

View file

@ -3,7 +3,7 @@ import std::vec;
import std::vec::plus_option; import std::vec::plus_option;
import front::ast; import front::ast;
import front::ast::*; import front::ast::*;
import option::*; import std::option::*;
import middle::walk::walk_crate; import middle::walk::walk_crate;
import middle::walk::walk_fn; import middle::walk::walk_fn;
import middle::walk::ast_visitor; import middle::walk::ast_visitor;

View file

@ -96,6 +96,7 @@ export mt;
export node_type_table; export node_type_table;
export pat_node_id; export pat_node_id;
export pat_ty; export pat_ty;
export cname;
export path_to_str; export path_to_str;
export rename; export rename;
export ret_ty_of_fn; export ret_ty_of_fn;
@ -170,6 +171,7 @@ export type_is_tup_like;
export type_is_str; export type_is_str;
export type_owns_heap_mem; export type_owns_heap_mem;
export type_param; export type_param;
export def_to_str;
export unify; export unify;
export variant_info; export variant_info;
export walk_ty; export walk_ty;
@ -273,7 +275,7 @@ tag sty {
type constr_def = spanned[constr_general[uint]]; type constr_def = spanned[constr_general[uint]];
type constr_general[T] = type constr_general[T] =
rec(path path, vec[@constr_arg_general[T]] args, def_id id); rec(ast::path path, vec[@constr_arg_general[T]] args, def_id id);
// Data structures used in type unification // Data structures used in type unification

View file

@ -1,13 +1,22 @@
import std::io; import std::io;
import std::vec;
import std::str;
import std::option;
import std::option::none;
import std::option::some;
import middle::ty::*; import middle::ty::*;
import front::lexer; import front::lexer;
import front::ast;
import pp::word; import pp::word;
import pp::eof; import pp::eof;
import pp::zerobreak; import pp::zerobreak;
import pp::hardbreak; import pp::hardbreak;
import front::codemap; import front::codemap;
import front::codemap::codemap; import front::codemap::codemap;
import util::common::istr;
import util::common::uistr;
import util::common::ty_mach_to_str;
fn ty_to_str(&ctxt cx, &t typ) -> str { fn ty_to_str(&ctxt cx, &t typ) -> str {
fn fn_input_to_str(&ctxt cx, &rec(middle::ty::mode mode, t ty) input) -> fn fn_input_to_str(&ctxt cx, &rec(middle::ty::mode mode, t ty) input) ->
@ -123,8 +132,8 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
fn ty_to_short_str(&ctxt cx, t typ) -> str { fn ty_to_short_str(&ctxt cx, t typ) -> str {
auto f = def_to_str; auto f = def_to_str;
auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::ac_no_abbrevs); auto ecx = @rec(ds=f, tcx=cx, abbrevs=middle::metadata::ac_no_abbrevs);
auto s = metadata::Encode::ty_str(ecx, typ); auto s = middle::metadata::Encode::ty_str(ecx, typ);
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); } if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
ret s; ret s;
} }

View file

@ -0,0 +1,14 @@
// error-pattern:unresolved name
import m1::*;
mod m1 {
export f1;
fn f1() {}
fn f2() {}
}
fn main () {
f2();
}

View file

@ -33,8 +33,8 @@ mod test1 {
assert(f1() == 1u); assert(f1() == 1u);
//make sure that cached lookups work... //make sure that cached lookups work...
assert(f1() == 1u); assert(f1() == 1u);
assert(f2() == 2u); //assert(f2() == 2u); //TODO: renable when 'reexport' is implemented
assert(f2() == 2u); //assert(f2() == 2u);
assert(common() == 1u); assert(common() == 1u);
assert(common() == 1u); assert(common() == 1u);
} }
@ -43,9 +43,9 @@ mod test1 {
mod test2 { mod test2 {
import circ2::*; import circ2::*;
fn test2() { fn test2() {
assert(f1() == 1u); //assert(f1() == 1u); //TODO: renable when 'reexport' is implemented
//make sure that cached lookups work... ////make sure that cached lookups work...
assert(f1() == 1u); //assert(f1() == 1u);
assert(f2() == 2u); assert(f2() == 2u);
assert(f2() == 2u); assert(f2() == 2u);
assert(common() == 2u); assert(common() == 2u);