mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
fixed scope lookup bug
This commit is contained in:
parent
0a77b3f334
commit
c7c421b2f5
19 changed files with 212 additions and 185 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::ident::{Ident, ModuleName};
|
||||
use crate::module_err::{ModuleIdNotFound, IdentIdNotFound, ModuleResult};
|
||||
use crate::module_err::{IdentIdNotFound, ModuleIdNotFound, ModuleResult};
|
||||
use roc_collections::all::{default_hasher, MutMap, SendMap};
|
||||
use roc_ident::IdentStr;
|
||||
use roc_region::all::Region;
|
||||
|
@ -255,24 +255,30 @@ impl Interns {
|
|||
pub fn from_index(module_id: ModuleId, ident_id: u32) -> Symbol {
|
||||
Symbol::new(module_id, IdentId(ident_id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_module_ident_ids(&self, module_id: &ModuleId) -> ModuleResult<&IdentIds> {
|
||||
self.all_ident_ids
|
||||
.get(module_id)
|
||||
.with_context(|| ModuleIdNotFound {
|
||||
module_id: format!("{:?}", module_id),
|
||||
all_ident_ids: format!("{:?}", self.all_ident_ids),
|
||||
})
|
||||
}
|
||||
pub fn get_module_ident_ids<'a>(
|
||||
all_ident_ids: &'a MutMap<ModuleId, IdentIds>,
|
||||
module_id: &ModuleId,
|
||||
) -> ModuleResult<&'a IdentIds> {
|
||||
all_ident_ids
|
||||
.get(module_id)
|
||||
.with_context(|| ModuleIdNotFound {
|
||||
module_id: format!("{:?}", module_id),
|
||||
all_ident_ids: format!("{:?}", all_ident_ids),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_module_ident_ids_mut(&mut self, module_id: &ModuleId) -> ModuleResult<&mut IdentIds> {
|
||||
self.all_ident_ids
|
||||
.get_mut(module_id)
|
||||
.with_context(|| ModuleIdNotFound {
|
||||
module_id: format!("{:?}", module_id),
|
||||
all_ident_ids: "I could not return all_ident_ids here because of borrowing issues.",
|
||||
})
|
||||
}
|
||||
pub fn get_module_ident_ids_mut<'a>(
|
||||
all_ident_ids: &'a mut MutMap<ModuleId, IdentIds>,
|
||||
module_id: &ModuleId,
|
||||
) -> ModuleResult<&'a mut IdentIds> {
|
||||
all_ident_ids
|
||||
.get_mut(module_id)
|
||||
.with_context(|| ModuleIdNotFound {
|
||||
module_id: format!("{:?}", module_id),
|
||||
all_ident_ids: "I could not return all_ident_ids here because of borrowing issues.",
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
@ -652,8 +658,7 @@ impl IdentIds {
|
|||
ident_ids_str: format!("{:?}", self),
|
||||
})?
|
||||
.as_inline_str()
|
||||
.as_str()
|
||||
)
|
||||
.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue