@@ -18,6 +18,7 @@ import std._vec;
18
18
tag scope {
19
19
scope_crate( @ast. crate ) ;
20
20
scope_item ( @ast. item ) ;
21
+ scope_loop ( @ast. decl ) ; // there's only 1 decl per loop.
21
22
scope_block ( ast. block ) ;
22
23
scope_arm ( ast. arm ) ;
23
24
}
@@ -317,6 +318,17 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] {
317
318
}
318
319
}
319
320
321
+ case ( scope_loop ( ?d) ) {
322
+ alt ( d. node ) {
323
+ case ( ast. decl_local ( ?local) ) {
324
+ if ( _str. eq ( local. ident , i) ) {
325
+ auto lc = ast. def_local ( local. id ) ;
326
+ ret some( def_wrap_other ( lc) ) ;
327
+ }
328
+ }
329
+ }
330
+ }
331
+
320
332
case ( scope_block ( ?b) ) {
321
333
alt ( b. node . index . find ( i) ) {
322
334
case ( some[ uint] ( ?ix) ) {
@@ -494,6 +506,16 @@ fn update_env_for_block(&env e, &ast.block b) -> env {
494
506
ret rec ( scopes = cons[ scope] ( scope_block ( b) , @e. scopes ) with e) ;
495
507
}
496
508
509
+ fn update_env_for_expr ( & env e, @ast. expr x ) -> env {
510
+ alt ( x. node ) {
511
+ case ( ast. expr_for ( ?d, _, _, _) ) {
512
+ ret rec ( scopes = cons[ scope] ( scope_loop ( d) , @e. scopes ) with e) ;
513
+ }
514
+ case ( _) { }
515
+ }
516
+ ret e;
517
+ }
518
+
497
519
fn update_env_for_arm ( & env e, & ast . arm p) -> env {
498
520
ret rec ( scopes = cons[ scope] ( scope_arm ( p) , @e. scopes ) with e) ;
499
521
}
@@ -507,7 +529,8 @@ fn resolve_imports(session.session sess, @ast.crate crate) -> @ast.crate {
507
529
update_env_for_crate = bind update_env_for_crate ( _, _) ,
508
530
update_env_for_item = bind update_env_for_item ( _, _) ,
509
531
update_env_for_block = bind update_env_for_block ( _, _) ,
510
- update_env_for_arm = bind update_env_for_arm ( _, _)
532
+ update_env_for_arm = bind update_env_for_arm ( _, _) ,
533
+ update_env_for_expr = bind update_env_for_expr ( _, _)
511
534
with * fld ) ;
512
535
513
536
auto e = rec ( scopes = nil[ scope] ,
@@ -528,7 +551,8 @@ fn resolve_crate(session.session sess, @ast.crate crate) -> @ast.crate {
528
551
update_env_for_crate = bind update_env_for_crate ( _, _) ,
529
552
update_env_for_item = bind update_env_for_item ( _, _) ,
530
553
update_env_for_block = bind update_env_for_block ( _, _) ,
531
- update_env_for_arm = bind update_env_for_arm ( _, _)
554
+ update_env_for_arm = bind update_env_for_arm ( _, _) ,
555
+ update_env_for_expr = bind update_env_for_expr ( _, _)
532
556
with * fld ) ;
533
557
534
558
auto e = rec ( scopes = nil[ scope] ,
0 commit comments