Repository navigation
fix(view source): put a space after the colon on a rest parameter - #19024
Merged
fdncred merged 1 commit intoSep 14, 2026
Merged
Conversation
`view source` rendered a rest parameter as `...rest:string` while every other
parameter kind in the same function gets a space after the colon:
def test [ a?: any --b: int ...rest:string] { echo 'test' }
Required positionals use `"{}: {} "`, optionals `"{}?: {} "`, flags `": {arg}"`.
Only the rest branch used `"...{}:{}"`. The command's own examples already show
`...rest: string`, in two places, so the documented form was right and the code
was not.
`view_source.rs` declared eight example results and had no test running them,
which is why the mismatch sat there. Add `test_examples` for the command. That
also caught a second, smaller mismatch: the module example claimed
`" export-env { ... }"` while `view source` returns the source between the
braces verbatim, trailing space included.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
ok, thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
view sourcerenders a rest parameter without a space after the colon, unlikeevery other parameter kind:
a?: anyand--b: intare spaced;...rest:stringis not. Inrender_defthe branches are:
"{}: {} ""{}?: {} "": {arg}""...{}:{}"The rest branch is the only one missing the space. The command's own examples
already show
...rest: string, in two of them, so the documented form was theright one and the code disagreed with it.
Why it was not caught:
view_source.rsdeclares eight example results and hadno test running them. Adding
test_examplesforViewSourceis what surfacedthis, and it also caught a second, smaller mismatch — the module example
claimed
while
view sourcereturns the source between the module's braces verbatim,so the real value has the trailing space too. That one is the example being
wrong rather than the code, so the example is corrected.
User-facing changes (Release notes)
view sourcenow renders a rest parameter as...rest: stringrather than...rest:string, matching how it already renders every other parameter.Tests + Formatting
Added
test_examplesforViewSource, which runs all eight declared exampleresults. It is not vacuous — it is what found both mismatches, failing first on
and then on the module example. Both are green now.
The full
nu-commandlib suite (815 tests) and the existingview_sourceintegration tests pass. I checked nothing asserted the old spelling: the only
other
...name:typein the tree is input source in an unrelated parser test,not an assertion on
view sourceoutput.cargo fmt --all -- --checkandcargo clippy --all-targetsare clean.Additional notes
Third small
nu-commandfix from me after #19017 and #19023, same theme: adeclared example result that nothing was checking.