File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -1374,7 +1374,7 @@ impl<O: OutputStream> Compiler<O> {
1374
1374
for ( i, element) in elements. iter ( ) . enumerate ( ) {
1375
1375
if let ast:: ExpressionType :: Starred { .. } = & element. node {
1376
1376
if seen_star {
1377
- return Err ( self . error ( CompileErrorType :: StarArgs ) ) ;
1377
+ return Err ( self . error ( CompileErrorType :: MultipleStarArgs ) ) ;
1378
1378
} else {
1379
1379
seen_star = true ;
1380
1380
self . emit ( Instruction :: UnpackEx {
@@ -1782,11 +1782,7 @@ impl<O: OutputStream> Compiler<O> {
1782
1782
self . compile_comprehension ( kind, generators) ?;
1783
1783
}
1784
1784
Starred { .. } => {
1785
- return Err (
1786
- self . error ( CompileErrorType :: SyntaxError ( std:: string:: String :: from (
1787
- "Invalid starred expression" ,
1788
- ) ) ) ,
1789
- ) ;
1785
+ return Err ( self . error ( CompileErrorType :: InvalidStarExpr ) ) ;
1790
1786
}
1791
1787
IfExpression { test, body, orelse } => {
1792
1788
let no_label = self . new_label ( ) ;
Original file line number Diff line number Diff line change @@ -47,7 +47,9 @@ pub enum CompileErrorType {
47
47
Parse ( ParseErrorType ) ,
48
48
SyntaxError ( String ) ,
49
49
/// Multiple `*` detected
50
- StarArgs ,
50
+ MultipleStarArgs ,
51
+ /// Misplaced `*` expression
52
+ InvalidStarExpr ,
51
53
/// Break statement outside of loop.
52
54
InvalidBreak ,
53
55
/// Continue statement outside of loop.
@@ -97,7 +99,10 @@ impl fmt::Display for CompileError {
97
99
CompileErrorType :: ExpectExpr => "Expecting expression, got statement" . to_owned ( ) ,
98
100
CompileErrorType :: Parse ( err) => err. to_string ( ) ,
99
101
CompileErrorType :: SyntaxError ( err) => err. to_string ( ) ,
100
- CompileErrorType :: StarArgs => "Two starred expressions in assignment" . to_owned ( ) ,
102
+ CompileErrorType :: MultipleStarArgs => {
103
+ "two starred expressions in assignment" . to_owned ( )
104
+ }
105
+ CompileErrorType :: InvalidStarExpr => "can't use starred expression here" . to_owned ( ) ,
101
106
CompileErrorType :: InvalidBreak => "'break' outside loop" . to_owned ( ) ,
102
107
CompileErrorType :: InvalidContinue => "'continue' outside loop" . to_owned ( ) ,
103
108
CompileErrorType :: InvalidReturn => "'return' outside function" . to_owned ( ) ,
You can’t perform that action at this time.
0 commit comments