mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 08:17:40 +03:00
Properly remove aliases from exposed_symbols
This commit is contained in:
parent
8eb91807e4
commit
0e6b75bc1c
@ -100,7 +100,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (defs, populated_scope, output) = canonicalize_defs(
|
let (defs, scope, output) = canonicalize_defs(
|
||||||
&mut env,
|
&mut env,
|
||||||
Output::default(),
|
Output::default(),
|
||||||
var_store,
|
var_store,
|
||||||
@ -155,13 +155,21 @@ pub fn canonicalize_module_defs<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (symbol, _alias) in scope.aliases() {
|
let mut aliases = MutMap::default();
|
||||||
|
|
||||||
|
for (symbol, alias) in scope.into_aliases() {
|
||||||
// Remove this from exposed_symbols,
|
// Remove this from exposed_symbols,
|
||||||
// so that at the end of the process,
|
// so that at the end of the process,
|
||||||
// we can see if there were any
|
// we can see if there were any
|
||||||
// exposed symbols which did not have
|
// exposed symbols which did not have
|
||||||
// corresponding defs.
|
// corresponding defs.
|
||||||
exposed_symbols.remove(symbol);
|
exposed_symbols.remove(&symbol);
|
||||||
|
|
||||||
|
// TODO store aliases as a MutMap inside Scope
|
||||||
|
// (and manually remove them when exiting a scope)
|
||||||
|
// and we can use it directly instead of rebuilding it
|
||||||
|
// piece by piece like this.
|
||||||
|
aliases.insert(symbol, alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
// By this point, all exposed symbols should have been removed from
|
// By this point, all exposed symbols should have been removed from
|
||||||
@ -180,12 +188,6 @@ pub fn canonicalize_module_defs<'a>(
|
|||||||
references.insert(symbol);
|
references.insert(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut aliases = MutMap::default();
|
|
||||||
|
|
||||||
for (symbol, alias) in populated_scope.aliases() {
|
|
||||||
aliases.insert(*symbol, alias.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(ModuleOutput {
|
Ok(ModuleOutput {
|
||||||
aliases,
|
aliases,
|
||||||
declarations,
|
declarations,
|
||||||
|
@ -42,8 +42,8 @@ impl Scope {
|
|||||||
self.symbols.iter()
|
self.symbols.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn aliases(&self) -> impl Iterator<Item = &(Symbol, Alias)> {
|
pub fn into_aliases(self) -> ImMap<Symbol, Alias> {
|
||||||
self.aliases.iter()
|
self.aliases
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contains_ident(&self, ident: &Ident) -> bool {
|
pub fn contains_ident(&self, ident: &Ident) -> bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user