Nushell math commands now accept ranges
Nushell #19604 added Type::Range to math sin/cos/tan, inverse and hyperbolic variants, ln and exp. The pipeline already handled ranges; the signature blocked them.
Nushell math commands accepted a list but not a range. A user had to convert a range to a list before calling math sin, math ln or math exp, even though the pipeline machinery already knew how to map over a range.
This is one of the pull requests behind Six merged PRs in 72 hours. The series looks at the failure, the fix and the review evidence, one merge at a time.
The change: +109 / -5 across 15 files. PR 19604.
The bug
The limitation was in the input signature, not the implementation. The command’s Type::Range was missing, so the parser rejected a value the runtime could have handled.
Unbounded ranges are still rejected, matching math sqrt. That is the correct boundary: an unbounded range has no finite list to map over.
Why it mattered
A shell is a composition language. If a range cannot flow into a math command, users write a conversion that allocates a list and obscures the intent. The fix makes the common expression 0..0.1..1 | math sin work directly.
The fix
Add Type::Range to the input signatures of math sin/cos/tan, their inverse and hyperbolic variants, math ln and math exp. The existing PipelineData::map path does the rest.
The evidence
Tests cover 0..10 for sin and exp and 1..10 for ln. cargo test -p nu-cmd-extra math:: passes, and the release note states that unbounded ranges are still rejected. The 15-file diff is mostly signatures and tests, not a new math engine.
What I would repeat
Check whether a limitation is in the type signature or the implementation. Here the runtime was ready; the contract was not. A small signature change can unlock a natural composition without new machinery.
Sources
If this was useful, connect with me on LinkedIn; I write about the bugs behind merged pull requests and the evidence that gets them accepted.
FAQ
- Which Nushell math commands accept ranges now?
- math sin, cos, tan, their inverse and hyperbolic variants, math ln and math exp.
- Do unbounded ranges work?
- No. They are still rejected, matching math sqrt.
- What was the actual fix?
- Adding Type::Range to the command signatures. The existing PipelineData::map path already handled ranges.
Join the Newsletter
Subscribe to get my latest content by email.
We won't send you spam. Unsubscribe at any time.