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:
Maria José Solano
2023-04-26 07:14:02 -07:00
committed by GitHub
parent 77ca73f414
commit e251f3a0b4
5 changed files with 31 additions and 7 deletions

View File

@ -323,8 +323,16 @@ fn default_value12() -> TestResult {
}
#[test]
fn default_value_expression() -> TestResult {
run_test(r#"def foo [x = ("foo" | str length)] { $x }; foo"#, "3")
fn default_value_constant() -> TestResult {
run_test(r#"def foo [x = "foo"] { $x }; foo"#, "foo")
}
#[test]
fn default_value_not_constant() -> TestResult {
fail_test(
r#"def foo [x = ("foo" | str length)] { $x }; foo"#,
"expected a constant",
)
}
#[test]