resolve regression in function scoping
This commit is contained in:
parent
f5e4c7e226
commit
947b4a3e15
@ -61,8 +61,9 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn eval_function(&mut self, mut function: Function, args: CallArgs) -> SassResult<Value> {
|
pub fn eval_function(&mut self, mut function: Function, args: CallArgs) -> SassResult<Value> {
|
||||||
self.scopes.push(self.scopes.last().clone());
|
|
||||||
self.eval_fn_args(&mut function, args)?;
|
self.eval_fn_args(&mut function, args)?;
|
||||||
|
self.scopes.push(function.scope);
|
||||||
|
|
||||||
let mut return_value = Parser {
|
let mut return_value = Parser {
|
||||||
toks: &mut function.body.into_iter().peekmore(),
|
toks: &mut function.body.into_iter().peekmore(),
|
||||||
map: self.map,
|
map: self.map,
|
||||||
@ -79,7 +80,9 @@ impl<'a> Parser<'a> {
|
|||||||
at_root_has_selector: self.at_root_has_selector,
|
at_root_has_selector: self.at_root_has_selector,
|
||||||
}
|
}
|
||||||
.parse()?;
|
.parse()?;
|
||||||
|
|
||||||
self.scopes.pop();
|
self.scopes.pop();
|
||||||
|
|
||||||
debug_assert!(return_value.len() <= 1);
|
debug_assert!(return_value.len() <= 1);
|
||||||
match return_value
|
match return_value
|
||||||
.pop()
|
.pop()
|
||||||
@ -91,11 +94,12 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn eval_fn_args(&mut self, function: &mut Function, mut args: CallArgs) -> SassResult<()> {
|
fn eval_fn_args(&mut self, function: &mut Function, mut args: CallArgs) -> SassResult<()> {
|
||||||
|
self.scopes.push(self.scopes.last().clone());
|
||||||
for (idx, arg) in function.args.0.iter_mut().enumerate() {
|
for (idx, arg) in function.args.0.iter_mut().enumerate() {
|
||||||
if arg.is_variadic {
|
if arg.is_variadic {
|
||||||
let span = args.span();
|
let span = args.span();
|
||||||
let arg_list = Value::ArgList(self.variadic_args(args)?);
|
let arg_list = Value::ArgList(self.variadic_args(args)?);
|
||||||
self.scopes.last_mut().insert_var(
|
function.scope.insert_var(
|
||||||
arg.name.clone(),
|
arg.name.clone(),
|
||||||
Spanned {
|
Spanned {
|
||||||
node: arg_list,
|
node: arg_list,
|
||||||
@ -117,8 +121,10 @@ impl<'a> Parser<'a> {
|
|||||||
};
|
};
|
||||||
self.scopes
|
self.scopes
|
||||||
.last_mut()
|
.last_mut()
|
||||||
.insert_var(mem::take(&mut arg.name), val)?;
|
.insert_var(arg.name.clone(), val.clone())?;
|
||||||
|
function.scope.insert_var(mem::take(&mut arg.name), val)?;
|
||||||
}
|
}
|
||||||
|
self.scopes.pop();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn eval_mixin_args(&mut self, mixin: &mut Mixin, mut args: CallArgs) -> SassResult<()> {
|
fn eval_mixin_args(&mut self, mixin: &mut Mixin, mut args: CallArgs) -> SassResult<()> {
|
||||||
let mut scope = self.scopes.last().clone();
|
self.scopes.push(self.scopes.last().clone());
|
||||||
for (idx, arg) in mixin.args.0.iter_mut().enumerate() {
|
for (idx, arg) in mixin.args.0.iter_mut().enumerate() {
|
||||||
if arg.is_variadic {
|
if arg.is_variadic {
|
||||||
let span = args.span();
|
let span = args.span();
|
||||||
@ -152,9 +152,12 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
scope.insert_var(arg.name.clone(), val.clone())?;
|
self.scopes
|
||||||
|
.last_mut()
|
||||||
|
.insert_var(arg.name.clone(), val.clone())?;
|
||||||
mixin.scope.insert_var(mem::take(&mut arg.name), val)?;
|
mixin.scope.insert_var(mem::take(&mut arg.name), val)?;
|
||||||
}
|
}
|
||||||
|
self.scopes.pop();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user