Fix broken assertion in regionck for code like (a[])()

This commit is contained in:
Niko Matsakis 2012-09-15 12:29:36 -07:00
parent 39d33a653f
commit 4cad58c464
2 changed files with 12 additions and 4 deletions

View File

@ -183,16 +183,15 @@ fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) {
// `constrain_auto_ref()` on all exprs. But that causes a
// lot of spurious errors because of how the region
// hierarchy is setup.
let tcx = rcx.fcx.tcx();
if rcx.fcx.ccx.method_map.contains_key(callee.id) {
match callee.node {
ast::expr_field(base, _, _) => {
constrain_auto_ref(rcx, base);
}
_ => {
tcx.sess.span_bug(
callee.span,
~"call of method that is not a field");
// This can happen if you have code like
// (x[0])() where `x[0]` is overloaded. Just
// ignore it.
}
}
} else {

View File

@ -0,0 +1,9 @@
use dvec::DVec;
fn foo() -> int { 22 }
fn main() {
let x = DVec::<@fn() -> int>();
x.push(foo);
assert (x[0])() == 22;
}