Skip to content

Confusing error when raising an integer to a negative power #15860

@kaathewisegit

Description

@kaathewisegit

Describe the bug

When an integer is raised by a negative power an operator overflow error is thrown, which I think is off. It should probably be a value error instead.

How to reproduce

~> 10 ** -1
Error: nu::shell::operator_overflow

  × Operator overflow.
   ╭─[entry #90:1:4]
 1  10 ** -1
   ·    ─┬
   ·     ╰── pow operation overflowed
   ╰────
  help: Consider using floating point values for increased range by promoting operand
        with 'into float'. Note: float has reduced precision!
~> 10 ** -1.0  # works fine
0.1
~> 10.0 ** -1  # also works fine
0.1

Expected behavior

I expected Nushell to throw a value error. Probably "unsupported input" like math ln does when its passed a negative number.

Configuration

key value
version 0.104.1
major 0
minor 104
patch 1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-alpine-linux-musl
rust_version rustc 1.87.0 (17067e9ac 2025-05-09) (Alpine Linux 1.87.0-r0)
cargo_version cargo 1.87.0 (99624be96 2025-05-06) (Alpine Linux 1.87.0-r0)
build_time 2025-05-26 22:14:00 +00:00
build_rust_channel release
allocator standard
features default, sqlite, trash
installed_plugins endecode 0.104.0, template 0.104.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-unhelpfulThe error message you observe is not helpful to identify the problemgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions