mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:35:56 +02:00
Change type of parameter default values to Option<Value>
(#8940)
# Description
Fixes #8939.
# User-Facing Changes
- Parameter default values will now be parsed as constants.
- If the default value is not a constant, a parser error is displayed.
# Tests + Formatting
The [only affected
test](d42c2b2dbc/src/tests/test_engine.rs (L325-L328)
)
has been updated to reflect the new behavior.
This commit is contained in:
committed by
GitHub
parent
77ca73f414
commit
e251f3a0b4
@ -3735,8 +3735,19 @@ pub fn parse_signature_helper(working_set: &mut StateWorkingSet, span: Span) ->
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*default_value = if let Ok(constant) =
|
||||
eval_constant(working_set, &expression)
|
||||
{
|
||||
Some(constant)
|
||||
} else {
|
||||
working_set.error(ParseError::NonConstantDefaultValue(
|
||||
expression.span,
|
||||
));
|
||||
None
|
||||
};
|
||||
|
||||
*shape = expression.ty.to_shape();
|
||||
*default_value = Some(expression);
|
||||
*required = false;
|
||||
}
|
||||
Arg::RestPositional(..) => {
|
||||
|
Reference in New Issue
Block a user