This repository was archived by the owner on Jul 27, 2023. It is now read-only.
File tree 2 files changed +10
-5
lines changed
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,14 @@ pub(crate) struct ArgumentList {
16
16
17
17
// Perform validation of function/lambda arguments in a function definition.
18
18
pub ( crate ) fn validate_arguments ( arguments : & ast:: Arguments ) -> Result < ( ) , LexicalError > {
19
- let mut all_arg_names = FxHashSet :: with_hasher ( Default :: default ( ) ) ;
19
+ let mut all_arg_names = FxHashSet :: with_capacity_and_hasher (
20
+ arguments. posonlyargs . len ( )
21
+ + arguments. args . len ( )
22
+ + arguments. vararg . is_some ( ) as usize
23
+ + arguments. kwonlyargs . len ( )
24
+ + arguments. kwarg . is_some ( ) as usize ,
25
+ Default :: default ( ) ,
26
+ ) ;
20
27
21
28
let posonlyargs = arguments. posonlyargs . iter ( ) ;
22
29
let args = arguments. args . iter ( ) ;
@@ -83,16 +90,14 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
83
90
Some ( ( start, end, name) ) => {
84
91
// Check for duplicate keyword arguments in the call.
85
92
if let Some ( keyword_name) = & name {
86
- if keyword_names. contains ( keyword_name) {
93
+ if ! keyword_names. insert ( keyword_name. clone ( ) ) {
87
94
return Err ( LexicalError {
88
95
error : LexicalErrorType :: DuplicateKeywordArgumentError (
89
96
keyword_name. to_string ( ) ,
90
97
) ,
91
98
location : start,
92
99
} ) ;
93
100
}
94
-
95
- keyword_names. insert ( keyword_name. clone ( ) ) ;
96
101
} else {
97
102
double_starred = true ;
98
103
}
Original file line number Diff line number Diff line change @@ -1104,7 +1104,7 @@ def args_to_tuple(*args: *Ts) -> Tuple[*Ts]: ...
1104
1104
#[ test]
1105
1105
#[ cfg( feature = "all-nodes-with-ranges" ) ]
1106
1106
fn decorator_ranges ( ) {
1107
- let parse_ast = parse_program (
1107
+ let parse_ast = ast :: Suite :: parse (
1108
1108
r#"
1109
1109
@my_decorator
1110
1110
def test():
You can’t perform that action at this time.
0 commit comments