mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Fix broken assertion in regionck for code like (a[])()
This commit is contained in:
parent
39d33a653f
commit
4cad58c464
@ -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 {
|
||||
|
9
src/test/run-pass/call-closure-from-overloaded-op.rs
Normal file
9
src/test/run-pass/call-closure-from-overloaded-op.rs
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user