mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-13 16:15:16 +00:00
Add Located::start
, Located::end
and impl Deref
This commit is contained in:
parent
3873414b30
commit
ae9d3c3193
4 changed files with 65 additions and 36 deletions
|
@ -35,12 +35,12 @@ pub(crate) fn validate_arguments(
|
|||
|
||||
let mut all_arg_names = FxHashSet::with_hasher(Default::default());
|
||||
for arg in all_args {
|
||||
let arg_name = &arg.node.arg;
|
||||
let arg_name = &arg.arg;
|
||||
// Check for duplicate arguments in the function definition.
|
||||
if !all_arg_names.insert(arg_name) {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::DuplicateArgumentError(arg_name.to_string()),
|
||||
location: arg.location,
|
||||
location: arg.start(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ pub(crate) fn parse_params(
|
|||
// have defaults.
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::DefaultArgumentError,
|
||||
location: name.location,
|
||||
location: name.start(),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
|
@ -126,14 +126,14 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
|
|||
if !keywords.is_empty() && !is_starred(&value) {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::PositionalArgumentError,
|
||||
location: value.location,
|
||||
location: value.start(),
|
||||
});
|
||||
// Allow starred arguments after keyword arguments but
|
||||
// not after double-starred arguments.
|
||||
} else if double_starred {
|
||||
return Err(LexicalError {
|
||||
error: LexicalErrorType::UnpackedArgumentError,
|
||||
location: value.location,
|
||||
location: value.start(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue