Print an error if we try to refer to a module in an expr_path.

This commit is contained in:
Rafael Ávila de Espíndola 2011-01-25 18:15:19 -05:00
parent 9e2324ad1e
commit 1b82060c5e
3 changed files with 22 additions and 1 deletions

View File

@ -504,6 +504,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
arg-count-mismatch.rs \
arg-type-mismatch.rs \
bad-expr-path.rs \
bad-expr-path2.rs \
import.rs \
import2.rs \
import3.rs \

View File

@ -444,7 +444,17 @@ fn fold_expr_path(&env e, &span sp, &ast.path p, &option.t[def] d,
// the expr_field(expr_field(...(expr_path(...)))) we should return.
auto index = new_def_hash[def_wrap]();
find_final_def(e, index, sp, p.node.idents, none[ast.def_id]);
auto d = find_final_def(e, index, sp, p.node.idents, none[ast.def_id]);
alt (d) {
case (def_wrap_expr_field(_)) {
}
case (def_wrap_other(_)) {
}
case (def_wrap_mod(?m)) {
e.sess.span_err(sp,
"can't refer to a module as a first-class value");
}
}
auto p_ = rec(node=rec(idents = vec(id0) with p.node) with p);
auto ex = @fold.respan[ast.expr_](sp, ast.expr_path(p_, d_, a));

View File

@ -0,0 +1,10 @@
// error-pattern: can't refer to a module as a first-class value
mod m1 {
mod a {
}
}
fn main(vec[str] args) {
log m1.a;
}