diff --git a/schala-lang/language/src/symbol_table/resolver.rs b/schala-lang/language/src/symbol_table/resolver.rs index 11fffca..8a58fba 100644 --- a/schala-lang/language/src/symbol_table/resolver.rs +++ b/schala-lang/language/src/symbol_table/resolver.rs @@ -19,6 +19,7 @@ enum ScopeType { Function { name: Rc }, + Lambda, //TODO add some notion of a let-like scope? } @@ -195,6 +196,23 @@ impl<'a> ASTVisitor for ScopeResolver<'a> { NamedStruct { name, fields: _ } => { self.lookup_name_in_scope(name); }, + Lambda { params, body, .. } => { + let param_names = params.iter().map(|param| param.name.clone()); + //TODO need to properly handle closure scope, this is currently broken + //let mut new_scope = self.lexical_scopes.new_scope(Some(ScopeType::Function { name: signature.name.clone() })); + let mut new_scope = ScopeStack::new(Some(ScopeType::Lambda)); + + for (n, param) in param_names.enumerate().into_iter() { + new_scope.insert(param, NameType::Param(n as u8)); + } + + let mut new_resolver = ScopeResolver { + symbol_table: self.symbol_table, + lexical_scopes: new_scope, + }; + walk_block(&mut new_resolver, body); + return Recursion::Stop; + } _ => (), } Recursion::Continue