use IdentStr

This commit is contained in:
Folkert 2021-08-03 21:14:36 +02:00
parent bd35770e9a
commit ceb5cc66fa
30 changed files with 241 additions and 219 deletions

View file

@ -1,7 +1,6 @@
use crate::procedure::References;
use inlinable_string::InlinableString;
use roc_collections::all::{MutMap, MutSet};
use roc_module::ident::ModuleName;
use roc_module::ident::{Ident, ModuleName};
use roc_module::symbol::{IdentIds, ModuleId, ModuleIds, Symbol};
use roc_problem::can::{Problem, RuntimeError};
use roc_region::all::{Located, Region};
@ -62,22 +61,21 @@ impl<'a> Env<'a> {
/// Returns Err if the symbol resolved, but it was not exposed by the given module
pub fn qualified_lookup(
&mut self,
module_name: &str,
module_name_str: &str,
ident: &str,
region: Region,
) -> Result<Symbol, RuntimeError> {
debug_assert!(
!module_name.is_empty(),
!module_name_str.is_empty(),
"Called env.qualified_lookup with an unqualified ident: {:?}",
ident
);
let module_name: InlinableString = module_name.into();
let module_name = ModuleName::from(module_name_str);
let ident = Ident::from(ident);
match self.module_ids.get_id(&module_name) {
Some(&module_id) => {
let ident: InlinableString = ident.into();
// You can do qualified lookups on your own module, e.g.
// if I'm in the Foo module, I can do a `Foo.bar` lookup.
if module_id == self.home {
@ -114,7 +112,7 @@ impl<'a> Env<'a> {
Ok(symbol)
}
None => Err(RuntimeError::ValueNotExposed {
module_name: ModuleName::from(module_name),
module_name,
ident,
region,
}),