diff --git a/src/parse/module.rs b/src/parse/module.rs index 9242c4e..2cd57fc 100644 --- a/src/parse/module.rs +++ b/src/parse/module.rs @@ -7,6 +7,7 @@ use crate::{ builtin::modules::{ declare_module_color, declare_module_list, declare_module_map, declare_module_math, declare_module_meta, declare_module_selector, declare_module_string, Module, ModuleConfig, + Modules, }, common::Identifier, error::SassResult, @@ -138,7 +139,7 @@ impl<'a, 'b> Parser<'a, 'b> { extender: self.extender, content_scopes: self.content_scopes, options: self.options, - modules: self.modules, + modules: &mut Modules::default(), module_config: config, } .parse()?; diff --git a/tests/use.rs b/tests/use.rs index 65b32b4..a02bde9 100644 --- a/tests/use.rs +++ b/tests/use.rs @@ -313,6 +313,45 @@ fn use_variable_redeclaration_private() { ); } +#[test] +fn use_cannot_see_modules_imported_by_other_modules() { + let input = r#" + @use "use_cannot_see_modules_imported_by_other_modules__a" as a; + @use "use_cannot_see_modules_imported_by_other_modules__b" as b;"#; + + tempfile!( + "use_cannot_see_modules_imported_by_other_modules__a.scss", + "$a: green;" + ); + tempfile!( + "use_cannot_see_modules_imported_by_other_modules__b.scss", + "a { color: a.$a; }" + ); + + assert_err!("Error: There is no module with the namespace \"a\".", input); +} + +#[test] +fn use_modules_imported_by_other_modules_does_not_cause_conflict() { + let input = r#" + @use "use_modules_imported_by_other_modules_does_not_cause_conflict__a" as a; + @use "use_modules_imported_by_other_modules_does_not_cause_conflict__b" as b;"#; + + tempfile!( + "use_modules_imported_by_other_modules_does_not_cause_conflict__a.scss", + "$a: red;" + ); + tempfile!( + "use_modules_imported_by_other_modules_does_not_cause_conflict__b.scss", + "@use \"use_modules_imported_by_other_modules_does_not_cause_conflict__a\" as a; a { color: a.$a; }" + ); + + assert_eq!( + "a {\n color: red;\n}\n", + &grass::from_string(input.to_string(), &grass::Options::default()).expect(input) + ); +} + #[test] fn use_variable_redeclaration_builtin() { let input = "@use \"sass:math\";\nmath.$e: red;";