diff --git a/schala-lang/language/src/scope_resolution.rs b/schala-lang/language/src/scope_resolution.rs index 50febf3..75586c7 100644 --- a/schala-lang/language/src/scope_resolution.rs +++ b/schala-lang/language/src/scope_resolution.rs @@ -21,27 +21,29 @@ impl<'a> ScopeResolver<'a> { match statement.kind { StatementKind::Declaration(ref decl) => self.decl(decl), StatementKind::Expression(ref expr) => self.expr(expr), - StatementKind::Import(ImportSpecifier { ref path_components, ref imported_names, .. }) => { - match imported_names { - ImportedNames::All => unimplemented!(), - ImportedNames::LastOfPath => { - let name = path_components.last().unwrap(); //TODO handle better - let fqsn_prefix = path_components.iter().map(|c| ScopeSegment { - name: c.clone(), kind: ScopeSegmentKind::Type - }).collect(); - self.name_scope_stack.insert(name.clone(), fqsn_prefix); - () - } - ImportedNames::List(ref names) => unimplemented!() - }; - //self.name_scope_stack.insert() - Ok(()) - } + StatementKind::Import(ref spec) => self.import(spec), }?; } Ok(()) } + fn import(&mut self, import_spec: &ImportSpecifier) -> Result<(), String> { + let ImportSpecifier { ref path_components, ref imported_names, .. } = &import_spec; + match imported_names { + ImportedNames::All => unimplemented!(), + ImportedNames::LastOfPath => { + let name = path_components.last().unwrap(); //TODO handle better + let fqsn_prefix = path_components.iter().map(|c| ScopeSegment { + name: c.clone(), kind: ScopeSegmentKind::Type + }).collect(); + self.name_scope_stack.insert(name.clone(), fqsn_prefix); + () + } + ImportedNames::List(ref names) => unimplemented!() + }; + Ok(()) + } + fn decl(&mut self, decl: &Declaration) -> Result<(), String> { use Declaration::*; match decl {