mirror of
https://github.com/nushell/nushell.git
synced 2025-06-08 11:06:55 +02:00
**Title**: Better error handling for negative integer exponents in `**` operator --- ### Bug Fix This PR addresses an issue where attempting to raise an integer to a negative power (e.g. `10 ** -1`) incorrectly triggered an `OperatorOverflow` error. This behavior was misleading since the overflow isn't actually the root problem — it's the unsupported operation of raising integers to negative powers. --- ### Fix Summary * Updated `Value::pow` to: * Check for negative exponents when both operands are integers. * Return a `ShellError::IncorrectValue` with a helpful message guiding users to use floating point values instead. #### Example: ```bash > 10 ** -1 Error: nu:🐚:incorrect_value × Incorrect value. ╝─[entry #2:1:4] 1 │ 10 ** -1 · ─┬┬ · │╰── encountered here · ╰── Negative exponent for integer power is unsupported; use floats instead. ``` --- ### Testing Manual testing: * `10 ** -1` → now returns a clear and appropriate `IncorrectValue` error. * `10.0 ** -1`, `10 ** -1.0`, etc. continue to work as expected. --- ### Related Fixes #15860 --------- Co-authored-by: Kumar Ujjawal <kumar.ujjawal@greenpista.com>
nu-protocol
The nu-protocol crate holds the definitions of structs/traits that are used throughout Nushell. This gives us one way to expose them to many other crates, as well as make these definitions available to each other, without causing mutually recursive dependencies.