mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
use IdentStr
This commit is contained in:
parent
bd35770e9a
commit
ceb5cc66fa
30 changed files with 241 additions and 219 deletions
|
@ -159,7 +159,7 @@ fn can_annotation_help(
|
|||
Err(problem) => {
|
||||
env.problem(roc_problem::can::Problem::RuntimeError(problem));
|
||||
|
||||
return Type::Erroneous(Problem::UnrecognizedIdent(ident.into()));
|
||||
return Type::Erroneous(Problem::UnrecognizedIdent(ident));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -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,
|
||||
}),
|
||||
|
|
|
@ -98,7 +98,7 @@ where
|
|||
// Here we essentially add those "defs" to "the beginning of the module"
|
||||
// by canonicalizing them right before we canonicalize the actual ast::Def nodes.
|
||||
for (ident, (symbol, region)) in exposed_imports {
|
||||
let first_char = ident.as_inline_str().chars().next().unwrap();
|
||||
let first_char = ident.as_inline_str().as_str().chars().next().unwrap();
|
||||
|
||||
if first_char.is_lowercase() {
|
||||
// this is a value definition
|
||||
|
|
|
@ -89,7 +89,7 @@ impl Scope {
|
|||
None => Err(RuntimeError::LookupNotInScope(
|
||||
Located {
|
||||
region,
|
||||
value: ident.clone().into(),
|
||||
value: ident.clone(),
|
||||
},
|
||||
self.idents.keys().map(|v| v.as_ref().into()).collect(),
|
||||
)),
|
||||
|
@ -124,9 +124,9 @@ impl Scope {
|
|||
// If this IdentId was already added previously
|
||||
// when the value was exposed in the module header,
|
||||
// use that existing IdentId. Otherwise, create a fresh one.
|
||||
let ident_id = match exposed_ident_ids.get_id(ident.as_inline_str()) {
|
||||
let ident_id = match exposed_ident_ids.get_id(&ident) {
|
||||
Some(ident_id) => *ident_id,
|
||||
None => all_ident_ids.add(ident.clone().into()),
|
||||
None => all_ident_ids.add(ident.clone()),
|
||||
};
|
||||
|
||||
let symbol = Symbol::new(self.home, ident_id);
|
||||
|
@ -143,7 +143,7 @@ impl Scope {
|
|||
///
|
||||
/// Used for record guards like { x: Just _ }
|
||||
pub fn ignore(&mut self, ident: Ident, all_ident_ids: &mut IdentIds) -> Symbol {
|
||||
let ident_id = all_ident_ids.add(ident.into());
|
||||
let ident_id = all_ident_ids.add(ident);
|
||||
Symbol::new(self.home, ident_id)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue