Skip to content

Fix bug: globbed imports were importing everything visible from the other module, not just everything exported. #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/comp/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/comp/middle/tstate/auxiliary.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import std::bitv;
import std::str;
import std::vec;
import std::vec::len;
import std::vec::grow;
Expand All @@ -12,6 +13,7 @@ import front::ast;
import front::ast::*;
import util::common;
import util::common::span;
import util::common::spanned;
import util::common::respan;
import util::common::log_block;
import util::common::new_int_hash;
Expand Down
2 changes: 1 addition & 1 deletion src/comp/middle/tstate/collect_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import std::vec;
import std::vec::plus_option;
import front::ast;
import front::ast::*;
import option::*;
import std::option::*;
import middle::walk::walk_crate;
import middle::walk::walk_fn;
import middle::walk::ast_visitor;
Expand Down
4 changes: 3 additions & 1 deletion src/comp/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export mt;
export node_type_table;
export pat_node_id;
export pat_ty;
export cname;
export path_to_str;
export rename;
export ret_ty_of_fn;
Expand Down Expand Up @@ -170,6 +171,7 @@ export type_is_tup_like;
export type_is_str;
export type_owns_heap_mem;
export type_param;
export def_to_str;
export unify;
export variant_info;
export walk_ty;
Expand Down Expand Up @@ -273,7 +275,7 @@ tag sty {
type constr_def = spanned[constr_general[uint]];

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
Expand Down
13 changes: 11 additions & 2 deletions src/comp/pretty/ppaux.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@

import std::io;
import std::vec;
import std::str;
import std::option;
import std::option::none;
import std::option::some;
import middle::ty::*;
import front::lexer;
import front::ast;
import pp::word;
import pp::eof;
import pp::zerobreak;
import pp::hardbreak;
import front::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 fn_input_to_str(&ctxt cx, &rec(middle::ty::mode mode, t ty) input) ->
Expand Down Expand Up @@ -123,8 +132,8 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {

fn ty_to_short_str(&ctxt cx, t typ) -> str {
auto f = def_to_str;
auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::ac_no_abbrevs);
auto s = metadata::Encode::ty_str(ecx, typ);
auto ecx = @rec(ds=f, tcx=cx, abbrevs=middle::metadata::ac_no_abbrevs);
auto s = middle::metadata::Encode::ty_str(ecx, typ);
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
ret s;
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/compile-fail/import-glob-export.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

// error-pattern:unresolved name

import m1::*;

mod m1 {
export f1;
fn f1() {}
fn f2() {}
}

fn main () {
f2();
}
10 changes: 5 additions & 5 deletions src/test/run-pass/import-glob-circular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ mod test1 {
assert(f1() == 1u);
//make sure that cached lookups work...
assert(f1() == 1u);
assert(f2() == 2u);
assert(f2() == 2u);
//assert(f2() == 2u); //TODO: renable when 'reexport' is implemented
//assert(f2() == 2u);
assert(common() == 1u);
assert(common() == 1u);
}
Expand All @@ -43,9 +43,9 @@ mod test1 {
mod test2 {
import circ2::*;
fn test2() {
assert(f1() == 1u);
//make sure that cached lookups work...
assert(f1() == 1u);
//assert(f1() == 1u); //TODO: renable when 'reexport' is implemented
////make sure that cached lookups work...
//assert(f1() == 1u);
assert(f2() == 2u);
assert(f2() == 2u);
assert(common() == 2u);
Expand Down