diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 6536748..13c8a5e 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -11,7 +11,6 @@ use crate::{ AtRuleKind, SupportsRule, UnknownAtRule, }, builtin::modules::{ModuleConfig, Modules}, - common::Identifier, error::SassResult, scope::{Scope, Scopes}, selector::{ @@ -133,41 +132,6 @@ impl<'a> Parser<'a> { } } - fn parse_module_variable_redeclaration(&mut self, module: Identifier) -> SassResult<()> { - let variable = self - .parse_identifier_no_interpolation(false)? - .map_node(|n| n.into()); - - self.whitespace_or_comment(); - self.expect_char(':')?; - - let VariableValue { - val_toks, - global, - default, - } = self.parse_variable_value()?; - - if global { - return Err(( - "!global isn't allowed for variables in other modules.", - variable.span, - ) - .into()); - } - - if default { - return Ok(()); - } - - let value = self.parse_value_from_vec(val_toks, true)?; - - self.modules - .get_mut(module, variable.span)? - .update_var(variable, value.node)?; - - Ok(()) - } - fn parse_stmt(&mut self) -> SassResult> { let mut stmts = Vec::new(); while let Some(Token { kind, pos }) = self.toks.peek() { diff --git a/src/parse/module.rs b/src/parse/module.rs index 6032026..ab6924a 100644 --- a/src/parse/module.rs +++ b/src/parse/module.rs @@ -9,9 +9,10 @@ use crate::{ declare_module_color, declare_module_list, declare_module_map, declare_module_math, declare_module_meta, declare_module_selector, declare_module_string, Module, ModuleConfig, }, + common::Identifier, error::SassResult, lexer::Lexer, - parse::{common::Comment, Parser, Stmt}, + parse::{common::Comment, Parser, Stmt, VariableValue}, scope::Scope, utils::peek_ident_no_interpolation, Token, @@ -248,4 +249,42 @@ impl<'a> Parser<'a> { Ok(comments) } + + pub(super) fn parse_module_variable_redeclaration( + &mut self, + module: Identifier, + ) -> SassResult<()> { + let variable = self + .parse_identifier_no_interpolation(false)? + .map_node(|n| n.into()); + + self.whitespace_or_comment(); + self.expect_char(':')?; + + let VariableValue { + val_toks, + global, + default, + } = self.parse_variable_value()?; + + if global { + return Err(( + "!global isn't allowed for variables in other modules.", + variable.span, + ) + .into()); + } + + if default { + return Ok(()); + } + + let value = self.parse_value_from_vec(val_toks, true)?; + + self.modules + .get_mut(module, variable.span)? + .update_var(variable, value.node)?; + + Ok(()) + } }