Repository navigation
Conversation
Per @Juhan280 review comment on get.rs:234 in nushell#18220. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Fixed in |
|
I think this is probably a pretty good change because it brings |
|
@mvanhorn it seems there is at least one test with spread that you haven't addressed. bad_spread_internal_args |
|
Pushed a follow-up addressing the bad_spread_internal_args failure properly. The earlier revision allowed a spread to satisfy required positionals at parse time but left them null at runtime. Spread elements are now distributed into unfilled required positionals at binding time (eval and IR paths), so |
|
CI is green again in 9bb700e. Root cause: the binding-time distribution change was type-checking optional positionals against their declared variable type, which std's assert internals trip over (cant_convert in try/catch paths). check_type now only runs for required positionals, matching the previous binding behavior for optionals. Verified locally: full std suite, get command tests (154), and spread tests (17) all pass. |
|
I'm fine with making get <cell-path> ...(rest)to get ...(rest)and making I really don't like the changes to how parameters in general are handled.
|
|
That works for me - I'd rather not weaken the general parameter binding either, and the fill-required / skip-optional / then-fill-rest ordering is genuinely surprising. Pushed the rework in bf89c46: get is now |
|
Merged main into the branch (5ec4e28). It had gone 330 commits stale and conflicted in tests/commands/get.rs; resolved, and it's mergeable again. The rework we settled on is unchanged: get is still |
There was a problem hiding this comment.
🟡 Changes recommended
Mixed literal/spread ordering and actual empty-spread syntax remain untested.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Enables get to accept spread cell-path arguments by making paths variadic and handling empty path lists as identity operations.
Changes:
- Flattens spread paths for runtime and const evaluation.
- Adds spread and no-path behavior tests/examples.
File summaries
| File | Description |
|---|---|
crates/nu-command/src/filters/get.rs |
Supports variadic and empty cell paths. |
crates/nu-command/tests/commands/get.rs |
Tests spread and identity behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Are we still moving forward here? Looks like there are conflicts. Please rebase on main, get the CI green and I'd like to do one more review. |
Make get's signature `get ...(rest)`, matching select: `get ...$columns` spreads straight into the rest argument, and `get` with no cell paths returns its input unchanged. Parameter binding is unchanged. Rebased onto main as a single commit. The earlier spread-binding experiments on this branch were reverted in review and are dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KFTE4BHbGYzgf8Uhzcppdh
5ec4e28 to
65a695c
Compare
|
Rebased onto main in 65a695c and resolved the conflict in get.rs, where run_const now takes the new stack argument. cargo build, cargo fmt --check, clippy and the full workspace tests are green here. Ready for another look. |
|
ok, let's do one more review. |
There was a problem hiding this comment.
Review overview
🟡 Changes recommended
The spread works and the tests pass, but the result's shape now depends on how long the spread list is at runtime, and get with no paths skips the empty-pipeline error that select reports.
Findings: 1
Open (8)
The output shape depends on how many paths the spread holdsgetwith no paths skips the empty-pipeline error Empty spread and one-element spread still have no testssplit_cell_pathsbuilds a (first, rest) pair thatactionjoins back together Strings in a spread are single column names, not paths New examples useValue::list(..., Span::test_data())instead ofValue::test_list Help text doesn't say what zero or one path returns The PR description doesn't match the diff. It lists acrates/nu-parser/src/parser.rschange (reverted in bf89c46) and tests for mixed and empty spreads that aren't in the diff. It also needs a release-notes line: the signature goes fromget <cell_path> ...(rest)toget ...(rest), andgetwith no arguments is no longer a parse error and returns its input.
Notes from my clanker, checked on 65a695c. Built the branch; the 29 commands::get tests and test_examples pass; probed spread, empty, null, const and stream cases on the branch binary and on 0.116.2.
…read-operator-for-get-command-rest-args
…first Address review: - A call with a spread argument now always returns one value per path, so `get ...$cols` has the same shape whether $cols holds zero, one or many names. An empty spread returns an empty list; bare `get` still returns its input. - The no-path case moves into `action`, after the PipelineData::Empty check, so `get` and `get ...[]` with no input report Pipeline empty like `select` does. This fixes `run` and `run_const` in one place. - `action` takes the Vec<CellPath> directly, which removes split_cell_paths and its let-else blocks. - The help text says what zero, one and several paths return, and that spread strings are single column names, with a `$.a.b` example for nested paths. The spread examples use Value::test_list. - Tests cover literal before and after a spread, one-element and empty spreads (literal and variable), nested cell-path spreads, a const spread, and the empty pipeline with no paths and with an empty spread.
|
when you're done, please respond to each review comment so we can be sure nothing was missed |
The help text said "With one literal cell path", but the fast path also applies to a single cell path held in a variable. Say "With one cell path and no spread" instead, as suggested in review.
|
Thanks |
|
Please change the PR body to follow the PR template since we use that for release notes. |



Summary
getnow takes its cell paths as a single...restparameter, so a list of paths can be spread into it:get ...$paths. Before this,getrequired a first cell path followed by a rest, and there was no way to pass a dynamically built list of paths.Behavior
getwith no paths returns its input unchanged. With an empty pipeline it reportsPipeline empty, the same asselect.get awith one cell path and no spread returns the value at that path, as before.get ...$colshas the same shape whatever$colsholds: one name gives a one-element list, and an empty spread gives an empty list....[a.b]looks for a column nameda.b. Nested paths are spread as cell-path values, for examplelet paths = [$.a.b]orinto cell-path.Changes
crates/nu-command/src/filters/get.rs: the signature isget ...(rest).actiontakes the fullVec<CellPath>, checks for an empty pipeline first, then branches on zero paths, one path without a spread, and everything else. A small helper reads whether the call has a spread argument (AST and IR calls). The help text and examples describe the zero, one and many cases and nested spread paths.crates/nu-command/tests/commands/get.rs: tests for literal before and after a spread, one-element spreads on a table and a record, empty literal and variable spreads, a nested cell-path spread, a const spread, and the empty pipeline with no paths and with an empty spread.Testing
On the merged branch:
cargo fmt --all -- --check,cargo clippy -p nu-command --all-targets -- -D warnings(with.cargo/ci.toml),cargo test -p nu-command --test tests -- commands::get(39 passed) and thegetexamples test all pass. Against the previousget.rs, 8 of the 10 new tests fail; the two mixed-order tests pass on both, since that ordering already worked.User-facing changes (Release notes)
getaccepts spread cell paths: get ...$pathsgetaccepts spread cell paths (get ...$paths). Its signature changes fromget <cell_path> ...(rest)toget ...(rest).getwith no arguments is no longer a parse error: it returns its input, or reportsPipeline emptywhen there is no input.getcall with a spread argument always returns a list, one value per path.Fixes #15801