Make none spreadable

This commit is contained in:
Laurenz 2021-10-10 12:16:28 +02:00
parent c0f5cd011f
commit f4ed775df0
2 changed files with 8 additions and 0 deletions

View File

@ -412,6 +412,7 @@ impl Eval for CallArgs {
});
}
CallArg::Spread(expr) => match expr.eval(ctx)? {
Value::None => {}
Value::Array(array) => {
items.extend(array.into_iter().map(|value| Arg {
span,

View File

@ -50,6 +50,13 @@
test(tostr(a: 1, ..more, b: 2), "(a: 1, c: 3, d: 4, b: 2)")
}
---
// None is spreadable.
#let f() = none
#f(..none)
#f(..if false {})
#f(..for x in () [])
---
// Error: 8-14 cannot spread string
#min(.."nope")