Skip to content

Commit b6e6f8b

Browse files
committed
Fix scope issue in resolution of alt-arm patterns
Closes #885
1 parent 87c6416 commit b6e6f8b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/comp/middle/resolve.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ fn resolve_names(e: &@env, c: &@ast::crate) {
275275
visit_item: visit_item_with_scope,
276276
visit_block: visit_block_with_scope,
277277
visit_decl: visit_decl_with_scope,
278-
visit_arm: walk_arm,
278+
visit_arm: visit_arm_with_scope,
279279
visit_pat: bind walk_pat(e, _, _, _),
280280
visit_expr: bind walk_expr(e, _, _, _),
281281
visit_ty: bind walk_ty(e, _, _, _),
@@ -310,9 +310,6 @@ fn resolve_names(e: &@env, c: &@ast::crate) {
310310
sc: &scopes, _v: &vt<scopes>) {
311311
maybe_insert(e, id, lookup_path_strict(*e, sc, sp, p.node, ns_value));
312312
}
313-
fn walk_arm(a: &ast::arm, sc: &scopes, v: &vt<scopes>) {
314-
visit_arm_with_scope(a, sc, v);
315-
}
316313
fn walk_pat(e: &@env, pat: &@ast::pat, sc: &scopes, v: &vt<scopes>) {
317314
visit::visit_pat(pat, sc, v);
318315
alt pat.node {
@@ -398,7 +395,10 @@ fn visit_decl_with_scope(d: &@decl, sc: &scopes, v: &vt<scopes>) {
398395
}
399396

400397
fn visit_arm_with_scope(a: &ast::arm, sc: &scopes, v: &vt<scopes>) {
401-
visit::visit_arm(a, cons(scope_arm(a), @sc), v);
398+
for p: @pat in a.pats { v.visit_pat(p, sc, v); }
399+
let sc_inner = cons(scope_arm(a), @sc);
400+
visit::visit_expr_opt(a.guard, sc_inner, v);
401+
v.visit_block(a.body, sc_inner, v);
402402
}
403403

404404
fn visit_expr_with_scope(x: &@ast::expr, sc: &scopes, v: &vt<scopes>) {

0 commit comments

Comments
 (0)