mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-14 06:15:27 +00:00
fix: Recover from missing argument in call expressions
Previously, when parsing an argument list with a missing argument (e.g., `(a, , b)` in `foo(a, , b)`), the parser would stop upon an unexpected token (at the second comma in the example), resulting in an incorrect parse tree. This commit improves error handling in such cases, ensuring a more accurate parse tree is built.
This commit is contained in:
parent
bcc8a09a0d
commit
e865d45904
4 changed files with 53 additions and 22 deletions
|
@ -68,6 +68,32 @@ SOURCE_FILE
|
|||
PLUS "+"
|
||||
R_PAREN ")"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n "
|
||||
EXPR_STMT
|
||||
CALL_EXPR
|
||||
PATH_EXPR
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "foo"
|
||||
ARG_LIST
|
||||
L_PAREN "("
|
||||
PATH_EXPR
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "a"
|
||||
COMMA ","
|
||||
WHITESPACE " "
|
||||
COMMA ","
|
||||
WHITESPACE " "
|
||||
PATH_EXPR
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "b"
|
||||
R_PAREN ")"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
|
@ -75,3 +101,4 @@ error 25: expected identifier
|
|||
error 39: expected COMMA
|
||||
error 39: expected expression
|
||||
error 55: expected expression
|
||||
error 68: expected expression
|
||||
|
|
|
@ -2,4 +2,5 @@ fn main() {
|
|||
foo(bar::);
|
||||
foo(bar:);
|
||||
foo(bar+);
|
||||
foo(a, , b);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue