remove unused value constructors from modules type info

This is a mildly scaring change, as it may horribly break things down
  the line if we have ever relied on that information... However, the
  value constructors inside each module are meant to reflect the own
  module public API, and shouldn't be populated with Prelude stuff. Not
  only does that mean this information is duplicated for all modules
  (possibly significantly slowing things down), but it may also cause
  weird scoping issues (e.g. one accessing a Prelude's constructor
  through some random module).

  Hence why I am isolating this change in this single commit, so it's
  easier to troubleshoot if that ends up causing weird issues.

Signed-off-by: KtorZ <matthias.benkort@gmail.com>
This commit is contained in:
KtorZ 2025-03-15 17:00:05 +01:00
parent 79a7d80c7f
commit c66bca5829
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
1 changed files with 12 additions and 1 deletions

View File

@ -17,7 +17,12 @@ use crate::{
tipo::{expr::infer_function, Span, Type, TypeVar}, tipo::{expr::infer_function, Span, Type, TypeVar},
IdGenerator, IdGenerator,
}; };
use std::{borrow::Borrow, collections::HashMap, ops::Deref, rc::Rc}; use std::{
borrow::Borrow,
collections::{BTreeSet, HashMap},
ops::Deref,
rc::Rc,
};
impl UntypedModule { impl UntypedModule {
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
@ -116,8 +121,14 @@ impl UntypedModule {
.module_types .module_types
.retain(|_, info| info.public && info.module == module_name); .retain(|_, info| info.public && info.module == module_name);
let own_types = environment.module_types.keys().collect::<BTreeSet<_>>();
environment.module_values.retain(|_, info| info.public); environment.module_values.retain(|_, info| info.public);
environment
.module_types_constructors
.retain(|k, _| own_types.contains(k));
environment environment
.accessors .accessors
.retain(|_, accessors| accessors.public); .retain(|_, accessors| accessors.public);