From 383eb7bb62ead55280f7f6948183b0f72f2975a6 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 2 Nov 2021 20:23:08 -0700 Subject: [PATCH] Use walk_if_expr_body --- schala-lang/language/src/symbol_table/mod.rs | 1 - .../language/src/symbol_table/resolver.rs | 38 +------------------ 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/schala-lang/language/src/symbol_table/mod.rs b/schala-lang/language/src/symbol_table/mod.rs index dda85e8..f177c53 100644 --- a/schala-lang/language/src/symbol_table/mod.rs +++ b/schala-lang/language/src/symbol_table/mod.rs @@ -222,7 +222,6 @@ impl SymbolTable { self.symbol_trie.insert(&fqsn, def_id); self.def_to_symbol.insert(def_id, symbol); } - } struct SymbolTableRunner<'a> { diff --git a/schala-lang/language/src/symbol_table/resolver.rs b/schala-lang/language/src/symbol_table/resolver.rs index ec2d851..c2c1aff 100644 --- a/schala-lang/language/src/symbol_table/resolver.rs +++ b/schala-lang/language/src/symbol_table/resolver.rs @@ -200,43 +200,7 @@ impl<'a> ASTVisitor for ScopeResolver<'a> { lexical_scopes: self.lexical_scopes.new_scope(Some(ScopeType::PatternMatch)), symbol_table: self.symbol_table, }; - let new_resolver = &mut resolver; - - match body.as_ref() { - IfExpressionBody::SimpleConditional { then_case, else_case } => { - walk_block(new_resolver, then_case); - if let Some(block) = else_case.as_ref() { - walk_block(new_resolver, block) - } - } - IfExpressionBody::SimplePatternMatch { pattern, then_case, else_case } => { - walk_pattern(new_resolver, pattern); - walk_block(new_resolver, then_case); - if let Some(block) = else_case.as_ref() { - walk_block(new_resolver, block) - } - } - IfExpressionBody::CondList(arms) => - for arm in arms { - match arm.condition { - Condition::Pattern(ref pat) => { - walk_pattern(new_resolver, pat); - } - Condition::TruncatedOp(ref _binop, ref expr) => { - walk_expression(new_resolver, expr); - } - Condition::Expression(ref expr) => { - walk_expression(new_resolver, expr); - } - Condition::Else => (), - } - if let Some(ref guard) = arm.guard { - walk_expression(new_resolver, guard); - } - walk_block(new_resolver, &arm.body); - }, - }; - + walk_if_expr_body(&mut resolver, body); return Recursion::Stop; } _ => (),