@@ -1437,8 +1437,10 @@ fn demand_block(&@fn_ctxt fcx, @ty.t expected, &ast.block bloc) -> ast.block {
1437
1437
1438
1438
// Writeback: the phase that writes inferred types back into the AST.
1439
1439
1440
- fn writeback_local( & @fn_ctxt fcx , & span sp, @ast. local local)
1440
+ fn writeback_local( & option . t [ @fn_ctxt] env , & span sp, @ast. local local)
1441
1441
-> @ast. decl {
1442
+ auto fcx = option. get[ @fn_ctxt] ( env) ;
1443
+
1442
1444
if ( !fcx. locals. contains_key( local. id) ) {
1443
1445
fcx. ccx. sess. span_err( sp, "unable to determine type of local: "
1444
1446
+ local. ident) ;
@@ -1452,10 +1454,25 @@ fn writeback_local(&@fn_ctxt fcx, &span sp, @ast.local local)
1452
1454
}
1453
1455
1454
1456
fn writeback( & @fn_ctxt fcx, & ast. block block) -> ast. block {
1455
- auto fld = fold. new_identity_fold[ @fn_ctxt] ( ) ;
1456
- auto f = writeback_local;
1457
- fld = @rec( fold_decl_local = f with * fld) ;
1458
- ret fold. fold_block[ @fn_ctxt] ( fcx, fld, block) ;
1457
+ fn update_env_for_item( & option. t[ @fn_ctxt] env, @ast. item i)
1458
+ -> option. t[ @fn_ctxt] {
1459
+ ret none[ @fn_ctxt] ;
1460
+ }
1461
+ fn keep_going( & option. t[ @fn_ctxt] env) -> bool {
1462
+ ret !option. is_none[ @fn_ctxt] ( env) ;
1463
+ }
1464
+
1465
+ auto fld = fold. new_identity_fold[ option. t[ @fn_ctxt] ] ( ) ;
1466
+ auto wbl = writeback_local;
1467
+ auto uefi = update_env_for_item;
1468
+ auto kg = keep_going;
1469
+ fld = @rec(
1470
+ fold_decl_local = wbl,
1471
+ update_env_for_item = uefi,
1472
+ keep_going = kg
1473
+ with * fld
1474
+ ) ;
1475
+ ret fold. fold_block[ option. t[ @fn_ctxt] ] ( some[ @fn_ctxt] ( fcx) , fld, block) ;
1459
1476
}
1460
1477
1461
1478
// AST fragment checking
0 commit comments