Skip to content

Commit d56f6fa

Browse files
committed
---
yaml --- r: 4420 b: refs/heads/master c: 9a5e980 h: refs/heads/master v: v3
1 parent 518b1b8 commit d56f6fa

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d4fe1b312797fb311351d27d1dce0cec735c808f
2+
refs/heads/master: 9a5e9806f3845731b9c4bdb1b986332ac9ed35b2

trunk/src/comp/middle/typeck.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,17 +1167,11 @@ mod writeback {
11671167
fn visit_item(item: &@ast::item, wbcx: &wb_ctxt, v: &wb_vt) {
11681168
// Ignore items
11691169
}
1170-
fn visit_fn(f: &ast::_fn, tps: &ast::ty_param[],
1171-
sp: &span, i: &ast::fn_ident, d: ast::node_id,
1172-
wbcx: &wb_ctxt, v: &wb_vt) {
1173-
// Ignore fns
1174-
}
11751170

11761171
fn resolve_type_vars_in_block(fcx: &@fn_ctxt, blk: &ast::blk) -> bool {
11771172
let wbcx = {fcx: fcx, mutable success: true};
11781173
let visit = visit::mk_vt
11791174
(@{visit_item: visit_item,
1180-
visit_fn: visit_fn,
11811175
visit_stmt: visit_stmt,
11821176
visit_expr: visit_expr,
11831177
visit_block: visit_block,
@@ -2647,7 +2641,6 @@ fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
26472641
check_block(fcx, body);
26482642
alt decl.purity {
26492643
ast::pure_fn. {
2650-
26512644
// This just checks that the declared type is bool, and trusts
26522645
// that that's the actual return type.
26532646
if !ty::type_is_bool(ccx.tcx, fcx.ret_ty) {
@@ -2669,7 +2662,13 @@ fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
26692662
}
26702663
}
26712664

2672-
writeback::resolve_type_vars_in_block(fcx, body);
2665+
// If we don't have any enclosing function scope, it is time to
2666+
// force any remaining type vars to be resolved.
2667+
// If we have an enclosing function scope, our type variables will be
2668+
// resolved when the enclosing scope finishes up.
2669+
if (option::is_none(old_fcx)) {
2670+
writeback::resolve_type_vars_in_block(fcx, body);
2671+
}
26732672
}
26742673

26752674
fn check_method(ccx: &@crate_ctxt, method: &@ast::method) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This should typecheck even though the type of e is not fully
2+
// resolved when we finish typechecking the lambda.
3+
fn main() {
4+
let e = @{mutable refs: ~[], n: 0};
5+
let f = lambda() { log_err e.n; };
6+
e.refs += ~[1];
7+
}

0 commit comments

Comments
 (0)