66use crate::ast;
77use crate::fstring::parse_located_fstring;
88use crate::function::{ArgumentList, parse_args, parse_params};
9- use crate::error::LexicalError;
9+ use crate::error::{ LexicalError, LexicalErrorType} ;
1010use crate::lexer;
1111use crate::token::StringKind;
1212
@@ -999,12 +999,29 @@ Atom: ast::Expr = {
999999 node: ast::ExprKind::ListComp { elt: Box::new(elt), generators }
10001000 }
10011001 },
1002- <location:@L> "(" <elements:TestOrStarNamedExprList?> ")" => {
1003- elements.unwrap_or(ast::Expr {
1004- location,
1005- custom: (),
1006- node: ast::ExprKind::Tuple { elts: Vec::new(), ctx: ast::ExprContext::Load }
1007- })
1002+ <location:@L> "(" <elements:TestOrStarNamedExprList?> ")" =>? {
1003+ match elements {
1004+ Some(elt) => {
1005+ match elt.node {
1006+ ast::ExprKind::Starred { .. } => {
1007+ Err(LexicalError{
1008+ error : LexicalErrorType::OtherError("cannot use starred expression here".to_string()),
1009+ location,
1010+ }.into())
1011+ },
1012+ _ => {
1013+ Ok(elt)
1014+ }
1015+ }
1016+ },
1017+ None => {
1018+ Ok(ast::Expr {
1019+ location,
1020+ custom: (),
1021+ node: ast::ExprKind::Tuple { elts: Vec::new(), ctx: ast::ExprContext::Load }
1022+ })
1023+ }
1024+ }
10081025 },
10091026 "(" <e:YieldExpr> ")" => e,
10101027 <location:@L> "(" <elt:Test> <generators:CompFor> ")" => {
@@ -1014,6 +1031,12 @@ Atom: ast::Expr = {
10141031 node: ast::ExprKind::GeneratorExp { elt: Box::new(elt), generators }
10151032 }
10161033 },
1034+ "(" <location:@L> "**" <e:Expression> ")" =>? {
1035+ Err(LexicalError{
1036+ error : LexicalErrorType::OtherError("cannot use double starred expression here".to_string()),
1037+ location,
1038+ }.into())
1039+ },
10171040 <location:@L> "{" <e:DictLiteralValues?> "}" => {
10181041 let (keys, values) = e.unwrap_or_default();
10191042 ast::Expr {
0 commit comments