modules use their own scope for module imports
this is a potentially breaking bugfix
This commit is contained in:
parent
100e7bad54
commit
d101a36f0c
@ -7,6 +7,7 @@ use crate::{
|
|||||||
builtin::modules::{
|
builtin::modules::{
|
||||||
declare_module_color, declare_module_list, declare_module_map, declare_module_math,
|
declare_module_color, declare_module_list, declare_module_map, declare_module_math,
|
||||||
declare_module_meta, declare_module_selector, declare_module_string, Module, ModuleConfig,
|
declare_module_meta, declare_module_selector, declare_module_string, Module, ModuleConfig,
|
||||||
|
Modules,
|
||||||
},
|
},
|
||||||
common::Identifier,
|
common::Identifier,
|
||||||
error::SassResult,
|
error::SassResult,
|
||||||
@ -138,7 +139,7 @@ impl<'a, 'b> Parser<'a, 'b> {
|
|||||||
extender: self.extender,
|
extender: self.extender,
|
||||||
content_scopes: self.content_scopes,
|
content_scopes: self.content_scopes,
|
||||||
options: self.options,
|
options: self.options,
|
||||||
modules: self.modules,
|
modules: &mut Modules::default(),
|
||||||
module_config: config,
|
module_config: config,
|
||||||
}
|
}
|
||||||
.parse()?;
|
.parse()?;
|
||||||
|
39
tests/use.rs
39
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]
|
#[test]
|
||||||
fn use_variable_redeclaration_builtin() {
|
fn use_variable_redeclaration_builtin() {
|
||||||
let input = "@use \"sass:math\";\nmath.$e: red;";
|
let input = "@use \"sass:math\";\nmath.$e: red;";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user