mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:06:08 +02:00
Empty rest args match should be an empty list (#14246)
Fixes #14145 # User-Facing Changes An empty rest match would be `null` previously. Now it will be an empty list. This is a breaking change for any scripts relying on the old behavior. Example script: ```nu match [1] { [_ ..$rest] => { match $rest { null => { "old" } [] => { "new" } } } } ``` This expression would evaluate to "old" on current nu versions and "new" with this patch.
This commit is contained in:
@ -64,6 +64,12 @@ fn match_list_rest() {
|
||||
assert_eq!(actual.out, "single: 1 5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_list_rest_empty() {
|
||||
let actual = nu!(r#"match [1] { [1 ..$rest] => { $rest == [] } }"#);
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_constant_1() {
|
||||
let actual = nu!(
|
||||
|
Reference in New Issue
Block a user