Skip to content

fix parse_calls negative number detection - #18514

Merged
Bahex merged 1 commit into
nushell:mainfrom
Tyarel8:negative-num-or-flag
Jul 12, 2026
Merged

Bahex merged 1 commit into
nushell:mainfrom
Tyarel8:negative-num-or-flag

Conversation

@Tyarel8

@Tyarel8 Tyarel8 commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Makes the negative number or short flag detection work with OneOff when the options can be negative numbers, necessary for the tests on #18511 to pass.

User-facing changes (Release notes)

Fixed negative arguments for oneof parameters

Parameters with int, float and number types can be supplied negative arguments:

def foo [p: int] {
    $p
}

foo -2
# => -2

However this didn't work with parameters with types like oneof<int, ...>:

def foo [p: <int, string>] {
    $p
}

foo -2
# => Error: nu::parser::unknown_flag
# => 
# =>   × The `foo` command doesn't have flag `-2`.
# =>    ╭─[repl_entry #1:3:6]
# =>  2 │ 
# =>  3 │ foo -2
# =>    ·      ┬
# =>    ·      ╰── unknown flag
# =>    ╰────
# =>   help: Use `--help` to see available flags

This is now fixed:

def foo [p: <int, string>] {
    $p
}

foo -2
# => -2

Additional notes

N/A

@github-actions github-actions Bot added the A:parser Issues related to parsing label Jul 3, 2026
@Bahex Bahex added status:wait-until-after-nushell-release notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Jul 3, 2026
@Bahex
Bahex merged commit ba94617 into nushell:main Jul 12, 2026
18 checks passed
@github-actions github-actions Bot added this to the v0.115.0 milestone Jul 12, 2026
@Tyarel8
Tyarel8 deleted the negative-num-or-flag branch July 12, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:parser Issues related to parsing notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes status:wait-until-after-nushell-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants