Error on negative argument of first (#7186)

Fixes a two's complement underflow/overflow when given a negative arg.

Breaking change as it is throwing an error instead of most likely
returning most of the output.

Same behavior as #7184


# Tests + Formatting

+ 1 failure test

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
Stefan Holderbach
2022-11-23 05:04:28 +01:00
committed by GitHub
parent ce03d8eb12
commit cf96677c78
2 changed files with 14 additions and 0 deletions

View File

@ -92,3 +92,16 @@ fn works_with_binary_list() {
assert_eq!(actual.out, "true");
}
#[test]
fn errors_on_negative_rows() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[1, 2, 3]
| first -10
"#
));
assert!(actual.err.contains("use a positive value"));
}