better error messages in args when missing { after function decl
This commit is contained in:
parent
cc881db254
commit
092cbe75bb
18
src/args.rs
18
src/args.rs
@ -199,12 +199,16 @@ pub(crate) fn eat_func_args<I: Iterator<Item = Token>>(
|
||||
super_selector: &Selector,
|
||||
) -> SassResult<FuncArgs> {
|
||||
let mut args: Vec<FuncArg> = Vec::new();
|
||||
let mut close_paren_span: Span = toks.peek().unwrap().pos();
|
||||
|
||||
devour_whitespace(toks);
|
||||
while let Some(Token { kind, .. }) = toks.next() {
|
||||
while let Some(Token { kind, pos }) = toks.next() {
|
||||
let name = match kind {
|
||||
'$' => eat_ident(toks, scope, super_selector)?,
|
||||
')' => break,
|
||||
')' => {
|
||||
close_paren_span = pos;
|
||||
break;
|
||||
}
|
||||
_ => todo!(),
|
||||
};
|
||||
let mut default: Vec<Token> = Vec::new();
|
||||
@ -234,6 +238,7 @@ pub(crate) fn eat_func_args<I: Iterator<Item = Token>>(
|
||||
default: Some(default),
|
||||
is_variadic,
|
||||
});
|
||||
close_paren_span = tok.pos();
|
||||
break;
|
||||
}
|
||||
_ => {
|
||||
@ -268,6 +273,7 @@ pub(crate) fn eat_func_args<I: Iterator<Item = Token>>(
|
||||
break;
|
||||
}
|
||||
')' => {
|
||||
close_paren_span = span;
|
||||
args.push(FuncArg {
|
||||
name: name.replace('_', "-"),
|
||||
default: if default.is_empty() {
|
||||
@ -289,10 +295,10 @@ pub(crate) fn eat_func_args<I: Iterator<Item = Token>>(
|
||||
devour_whitespace(toks);
|
||||
}
|
||||
devour_whitespace(toks);
|
||||
if let Some(Token { kind: '{', .. }) = toks.next() {
|
||||
} else {
|
||||
todo!("expected `{{` after args")
|
||||
}
|
||||
match toks.next() {
|
||||
Some(v) if v.kind == '{' => {}
|
||||
Some(..) | None => return Err(("expected \"{\".", close_paren_span).into()),
|
||||
};
|
||||
Ok(FuncArgs(args))
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ impl Css {
|
||||
._inner_pretty_print(buf, nesting + 1)?;
|
||||
writeln!(buf, "{}}}", padding)?;
|
||||
}
|
||||
_ => todo!("at-rule other than unknown at toplevel"),
|
||||
_ => todo!("at-rule other than unknown at toplevel: {:?}", r),
|
||||
},
|
||||
Toplevel::Style(s) => {
|
||||
writeln!(buf, "{}{}", padding, s.to_string()?)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user