mirror of
https://github.com/nushell/nushell.git
synced 2025-08-17 11:11:08 +02:00
Change type of flag defaults to Option<Value> (#9085)
# Description
Follow-up of #8940. As @bobhy pointed out, it makes sense for the
behaviour of flags to match the one for positional arguments, where
default values are of type `Option<Value>` instead of
`Option<Expression>`.
# User-Facing Changes
The same ones from the original PR:
- Flag default values will now be parsed as constants.
- If the default value is not a constant, a parser error is displayed.
# Tests + Formatting
A [new
test](e34e2d35f4/src/tests/test_engine.rs (L338-L344)
)
has been added to verify the new restriction.
This commit is contained in:
committed by
GitHub
parent
e4625acf24
commit
d9a00a876b
@ -328,13 +328,21 @@ fn default_value_constant() -> TestResult {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_value_not_constant() -> TestResult {
|
||||
fn default_value_not_constant1() -> TestResult {
|
||||
fail_test(
|
||||
r#"def foo [x = ("foo" | str length)] { $x }; foo"#,
|
||||
"expected a constant",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_value_not_constant2() -> TestResult {
|
||||
fail_test(
|
||||
r#"def foo [--x = ("foo" | str length)] { $x }; foo"#,
|
||||
"expected a constant",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loose_each() -> TestResult {
|
||||
run_test(
|
||||
|
Reference in New Issue
Block a user