Skip to content

Commit b822dc2

Browse files
committed
---
yaml --- r: 1271 b: refs/heads/master c: c9d2ece h: refs/heads/master i: 1269: 89bdd70 1267: a484534 1263: b9c87d5 v: v3
1 parent c6ecced commit b822dc2

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
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: a8af013077c01901426f7cb829a98c7f1fbe6613
2+
refs/heads/master: c9d2eceb4588e5fe57be4cbd41dbab789f9ecb29

trunk/src/comp/middle/resolve.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import std._vec;
1818
tag scope {
1919
scope_crate(@ast.crate);
2020
scope_item(@ast.item);
21+
scope_loop(@ast.decl); // there's only 1 decl per loop.
2122
scope_block(ast.block);
2223
scope_arm(ast.arm);
2324
}
@@ -317,6 +318,17 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] {
317318
}
318319
}
319320

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+
320332
case (scope_block(?b)) {
321333
alt (b.node.index.find(i)) {
322334
case (some[uint](?ix)) {
@@ -494,6 +506,16 @@ fn update_env_for_block(&env e, &ast.block b) -> env {
494506
ret rec(scopes = cons[scope](scope_block(b), @e.scopes) with e);
495507
}
496508

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+
497519
fn update_env_for_arm(&env e, &ast.arm p) -> env {
498520
ret rec(scopes = cons[scope](scope_arm(p), @e.scopes) with e);
499521
}
@@ -507,7 +529,8 @@ fn resolve_imports(session.session sess, @ast.crate crate) -> @ast.crate {
507529
update_env_for_crate = bind update_env_for_crate(_,_),
508530
update_env_for_item = bind update_env_for_item(_,_),
509531
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(_,_)
511534
with *fld );
512535

513536
auto e = rec(scopes = nil[scope],
@@ -528,7 +551,8 @@ fn resolve_crate(session.session sess, @ast.crate crate) -> @ast.crate {
528551
update_env_for_crate = bind update_env_for_crate(_,_),
529552
update_env_for_item = bind update_env_for_item(_,_),
530553
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(_,_)
532556
with *fld );
533557

534558
auto e = rec(scopes = nil[scope],

0 commit comments

Comments
 (0)