Call args span now includes parens
This commit is contained in:
parent
e35fca54a0
commit
fbd3d19113
@ -303,7 +303,7 @@ fn primary(p: &mut Parser, atomic: bool) -> Option<Expr> {
|
||||
match p.peek() {
|
||||
// Things that start with an identifier.
|
||||
Some(Token::Ident(string)) => {
|
||||
let id = Ident {
|
||||
let ident = Ident {
|
||||
span: p.eat_span(),
|
||||
string: string.into(),
|
||||
};
|
||||
@ -312,13 +312,13 @@ fn primary(p: &mut Parser, atomic: bool) -> Option<Expr> {
|
||||
Some(if !atomic && p.eat_if(Token::Arrow) {
|
||||
let body = expr(p)?;
|
||||
Expr::Closure(ClosureExpr {
|
||||
span: id.span.join(body.span()),
|
||||
span: ident.span.join(body.span()),
|
||||
name: None,
|
||||
params: Rc::new(vec![id]),
|
||||
params: Rc::new(vec![ident]),
|
||||
body: Rc::new(body),
|
||||
})
|
||||
} else {
|
||||
Expr::Ident(id)
|
||||
Expr::Ident(ident)
|
||||
})
|
||||
}
|
||||
|
||||
@ -537,12 +537,7 @@ fn call(p: &mut Parser, callee: Expr) -> Option<Expr> {
|
||||
}
|
||||
|
||||
let mut args = match p.peek_direct() {
|
||||
Some(Token::LeftParen) => {
|
||||
p.start_group(Group::Paren, TokenMode::Code);
|
||||
let args = args(p);
|
||||
p.end_group();
|
||||
args
|
||||
}
|
||||
Some(Token::LeftParen) => args(p),
|
||||
Some(Token::LeftBracket) => CallArgs {
|
||||
span: Span::at(callee.span().end),
|
||||
items: vec![],
|
||||
@ -568,22 +563,19 @@ fn call(p: &mut Parser, callee: Expr) -> Option<Expr> {
|
||||
|
||||
/// Parse the arguments to a function call.
|
||||
fn args(p: &mut Parser) -> CallArgs {
|
||||
let start = p.next_start();
|
||||
p.start_group(Group::Paren, TokenMode::Code);
|
||||
let items = collection(p).0;
|
||||
CallArgs { span: p.span(start), items }
|
||||
let span = p.end_group();
|
||||
CallArgs { span, items }
|
||||
}
|
||||
|
||||
/// Parse a with expression.
|
||||
fn with_expr(p: &mut Parser, callee: Expr) -> Option<Expr> {
|
||||
if p.peek() == Some(Token::LeftParen) {
|
||||
p.start_group(Group::Paren, TokenMode::Code);
|
||||
let args = args(p);
|
||||
p.end_group();
|
||||
|
||||
Some(Expr::With(WithExpr {
|
||||
span: p.span(callee.span().start),
|
||||
callee: Box::new(callee),
|
||||
args,
|
||||
args: args(p),
|
||||
}))
|
||||
} else {
|
||||
p.expected("argument list");
|
||||
|
@ -71,7 +71,7 @@
|
||||
let types(x, y) = "[" + type(x) + ", " + type(y) + "]"
|
||||
test(types(14%, 12pt), "[relative, length]")
|
||||
|
||||
// Error: 14-20 missing argument: y
|
||||
// Error: 13-21 missing argument: y
|
||||
test(types("nope"), "[string, none]")
|
||||
}
|
||||
|
||||
|
@ -15,5 +15,5 @@ Relative #h(100%) spacing
|
||||
|
||||
---
|
||||
// Missing spacing.
|
||||
// Error: 12 missing argument: spacing
|
||||
// Error: 11-13 missing argument: spacing
|
||||
Totally #h() ignored
|
||||
|
@ -9,7 +9,7 @@
|
||||
#test(len((a: 1, b: 2)), 2)
|
||||
|
||||
---
|
||||
// Error: 6 missing argument: collection
|
||||
// Error: 5-7 missing argument: collection
|
||||
#len()
|
||||
|
||||
---
|
||||
|
@ -16,9 +16,9 @@
|
||||
#rgb("lol")
|
||||
|
||||
---
|
||||
// Error: 6 missing argument: red component
|
||||
// Error: 5-7 missing argument: red component
|
||||
#rgb()
|
||||
|
||||
---
|
||||
// Error: 6-10 missing argument: blue component
|
||||
// Error: 5-11 missing argument: blue component
|
||||
#rgb(0, 1)
|
||||
|
@ -9,9 +9,9 @@
|
||||
#test(min("hi"), "hi")
|
||||
|
||||
---
|
||||
// Error: 6 missing argument: value
|
||||
// Error: 5-7 missing argument: value
|
||||
#min()
|
||||
|
||||
---
|
||||
// Error: 11-18 cannot compare integer with string
|
||||
// Error: 10-19 cannot compare integer with string
|
||||
#test(min(1, "hi"), error)
|
||||
|
Loading…
Reference in New Issue
Block a user