scope.lookup_str

This commit is contained in:
Folkert 2022-05-17 20:48:20 +02:00
parent b241bcf777
commit 95bf8bb505
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 10 additions and 6 deletions

View file

@ -50,15 +50,19 @@ impl Scope {
}
pub fn lookup(&self, ident: &Ident, region: Region) -> Result<Symbol, RuntimeError> {
self.lookup_str(ident.as_str(), region)
}
pub fn lookup_str(&self, ident: &str, region: Region) -> Result<Symbol, RuntimeError> {
use ContainsIdent::*;
match self.scope_contains_ident(ident.as_str()) {
match self.scope_contains_ident(ident) {
InScope(symbol, _) => Ok(symbol),
NotInScope(_) | NotPresent => {
let error = RuntimeError::LookupNotInScope(
Loc {
region,
value: ident.clone(),
value: Ident::from(ident),
},
self.idents_in_scope().map(|v| v.as_ref().into()).collect(),
);