nushell/tests/repl
Andreas Källberg 8200831b07
Fix panic on too few arguments for custom function (#10395)
# Description
Old code was comparing remaining positional arguments with total number
of arguments, where it should've compared remaining positional with
with remaining arguments of any kind. This means that if a function was
given too few arguments, `calculate_end_span` would believe that it
actually had too many arguments, since after parsing the first few
arguments, the number of remaining arguments needed were fewer than the
*total* number of arguments, of which we had used several.

Fixes #9072
Fixes: https://github.com/nushell/nushell/issues/13930
Fixes: https://github.com/nushell/nushell/issues/12069
Fixes: https://github.com/nushell/nushell/issues/8385

Extracted from #10381

## Bonus

It also improves the error handling on missing positional arguments
before keywords (no longer crashing since #9851). Instead of just giving
the keyword to the parser for the missing positional, we give an
explicit error about a missing positional argument. I would like better
descriptions than "missing var_name" though, but I'm not sure if that's
available without

Old error
```
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #1:1:1]
 1 │ let = if foo
   ·     ┬
   ·     ╰── expected valid variable name
   ╰────
```

New error
```
Error: nu::parser::missing_positional

  × Missing required positional argument.
   ╭─[entry #18:1:1]
 1 │ let = foo
   ·    ┬
   ·    ╰── missing var_name
   ╰────
  help: Usage: let <var_name> = <initial_value>
```

# User-Facing Changes
The program `alias = = =` is no longer accepted by the parser
2024-09-27 23:39:45 +08:00
..
mod.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_bits.rs Fix bits ror/bits rol implementation (#13673) 2024-08-22 21:22:10 +02:00
test_cell_path.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_commandline.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_conditionals.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_config_path.rs Path migration part 4: various tests (#13373) 2024-08-03 10:09:13 +02:00
test_config.rs Make assignment and const consistent with let/mut (#13385) 2024-07-30 18:55:22 -05:00
test_converters.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_custom_commands.rs Make parsing for unknown args in known externals like normal external calls (#13414) 2024-07-21 01:32:36 -07:00
test_engine.rs Fix $in in range expressions (#13447) 2024-07-25 18:28:44 +08:00
test_env.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_help.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_hiding.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_ide.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_iteration.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_known_external.rs Make parsing for unknown args in known externals like normal external calls (#13414) 2024-07-21 01:32:36 -07:00
test_math.rs Fix bugs and UB in bit shifting ops (#13663) 2024-08-22 11:54:27 +02:00
test_modules.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_parser.rs Fix panic on too few arguments for custom function (#10395) 2024-09-27 23:39:45 +08:00
test_ranges.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_regex.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_signatures.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_spread.rs Rewrite run_external.rs (#12921) 2024-05-23 02:05:27 +00:00
test_stdlib.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_strings.rs Restrict strings beginning with quote should also ending with quote (#13131) 2024-06-28 09:47:12 +08:00
test_table_operations.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_type_check.rs Overhaul $in expressions (#13357) 2024-07-17 16:02:42 -05:00
tests.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00