Skip to content

Commit d9520e0

Browse files
committed
[FIX] server: posonly args can have a default value
1 parent a73e9b4 commit d9520e0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

server/src/core/evaluation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ impl Evaluation {
13751375
found_pos_arg_with_kw = number_pos_arg;
13761376
}
13771377
}
1378-
if found_pos_arg_with_kw + 1 < number_pos_arg {
1378+
if found_pos_arg_with_kw < number_pos_arg {
13791379
if let Some(diagnostic) = create_diagnostic(session, DiagnosticCode::OLS01007, &[&function.name, &number_pos_arg.to_string(), &arg_index.to_string()]) {
13801380
diagnostics.push(Diagnostic {
13811381
range: Range::new(Position::new(expr_call.range().start().to_u32(), 0), Position::new(expr_call.range().end().to_u32(), 0)),

server/src/core/python_arch_builder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,13 @@ impl PythonArchBuilder {
683683
for arg in func_def.parameters.posonlyargs.iter() {
684684
let param = sym.borrow_mut().add_new_variable(session, oyarn!("{}", arg.parameter.name.id), &arg.range);
685685
param.borrow_mut().as_variable_mut().is_parameter = true;
686+
let mut default = None;
687+
if arg.default.is_some() {
688+
default = Some(Evaluation::new_none()); //TODO evaluate default? actually only used to know if there is a default or not
689+
}
686690
sym.borrow_mut().as_func_mut().args.push(Argument {
687691
symbol: Rc::downgrade(&param),
688-
default_value: None,
692+
default_value: default,
689693
arg_type: ArgumentType::POS_ONLY,
690694
annotation: arg.parameter.annotation.clone(),
691695
});

0 commit comments

Comments
 (0)