Skip to content

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

Closed

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

Activity

  1. added
    status:needs-triage
    on May 31, 2025
  2. changed the title [-]Confusing numerical error when raising an integer to a negative power[/-] [+]Confusing error when raising an integer to a negative power[/+] on May 31, 2025
  3. added
    A:error-unhelpful
    good first issue
    and removed
    status:needs-triage
    on Jun 1, 2025
  4. added this to the v0.105.0 milestone on Jun 4, 2025
  5. added a commit that references this issue on Jun 4, 2025
    fc813af
  6. added 3 commits that reference this issue on Jun 5, 2025
    0e65e73
    445ec5c
    5f1c712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-unhelpfulgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions