mirror of
https://github.com/nushell/nushell.git
synced 2025-08-17 00:51:16 +02:00
don't allow break/continue in each
and items
command (#13398)
# Description Fixes: #11451 # User-Facing Changes ### Before ```nushell ❯ [1 2 3] | each {|e| break; print $e } ╭────────────╮ │ empty list │ ╰────────────╯ ``` ### After ``` ❯ [1 2 3] | each {|e| break; print $e } Error: nu:🐚:eval_block_with_input × Eval block failed with pipeline input ╭─[entry #9:1:2] 1 │ [1 2 3] | each {|e| break; print $e } · ┬ · ╰── source value ╰──── Error: × Break used outside of loop ╭─[entry #9:1:21] 1 │ [1 2 3] | each {|e| break; print $e } · ──┬── · ╰── used outside of loop ╰──── ``` # Tests + Formatting Removes some tests.
This commit is contained in:
@ -15,12 +15,3 @@ fn break_while_loop() {
|
||||
|
||||
assert_eq!(actual.out, "hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn break_each() {
|
||||
let actual = nu!("
|
||||
[1, 2, 3, 4, 5] | each {|x| if $x > 3 { break }; $x} | math sum
|
||||
");
|
||||
|
||||
assert_eq!(actual.out, "6");
|
||||
}
|
||||
|
Reference in New Issue
Block a user