diff --git a/sway-core/src/optimize.rs b/sway-core/src/optimize.rs index 2b50f510715..4e723e37cfe 100644 --- a/sway-core/src/optimize.rs +++ b/sway-core/src/optimize.rs @@ -123,7 +123,10 @@ fn compile_constants( } } - for ns in namespace.get_all_imported_modules() { + for ns in namespace + .get_all_imported_modules() + .filter(|&ns| ns == namespace) + { compile_constants(context, module, ns, true)?; } diff --git a/sway-core/src/semantic_analysis/namespace.rs b/sway-core/src/semantic_analysis/namespace.rs index 7ff5e40842f..b2497a24feb 100644 --- a/sway-core/src/semantic_analysis/namespace.rs +++ b/sway-core/src/semantic_analysis/namespace.rs @@ -27,7 +27,7 @@ type UseAliases = im::HashMap; /// importing. /// /// The namespace is constructed during type checking. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct Namespace { // This is a BTreeMap because we rely on its ordering being consistent. See // [Namespace::get_all_declared_symbols] -- we need that iterator to have a deterministic @@ -855,7 +855,7 @@ impl Namespace { type TraitMapInner = im::Vector<((TraitName, TypeInfo), TraitMethods)>; type TraitMethods = im::HashMap; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub(crate) struct TraitMap { trait_map: TraitMapInner, }