nushell / nushell/nushell

Parsing of table literal as an argument is inconsistent

Open
#13,537 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:parser category:inconsistent-behavior
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

It appears that parsing of the header form of table literals is incorrect for at least the table argument of the join command. Perhaps this happens for other commands, too?

How to reproduce

Run this script:

use std assert

# start figuring out the relation between islands in Riven :grin:

let list_of_records = [{"island name": boiler}]
let table = [["island name"]; [boiler]]

assert ($list_of_records == $table)
assert (($list_of_records | join $list_of_records "island name") == $table)

assert (($table | join $list_of_records "island name") == $table)
assert (($table | join ([{"island name": boiler}]) "island name") == $table)
assert (($table | join [{"island name": boiler}] "island name") == $table)

assert (($table | join $table "island name") == $table)
assert (($table | join ([["island name"]; [boiler]]) "island name") == $table)
assert (($table | join [["island name"]; [boiler]] "island name") == $table) # fails :'(
Expected behavior

The final line:

assert (($table | join [["island name"]; [boiler]] "island name") == $table) # fails :'(

…should not fail its assert call.

Screenshots

No response

Configuration
key value
version 0.96.1
major 0
minor 96
patch 1
branch
commit_hash
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.79.0 (129f3b996 2024-06-10) (Homebrew)
cargo_version cargo 1.79.0
build_time 2024-07-29 23:31:36 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, system-clipboard, trash
installed_plugins
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproduction script from the issue and compare the passing and failing join invocations. Trace how the Nushell parser handles header-form table literals when they are passed directly as command arguments. Done means the final assertion passes consistently without changing the equivalent parenthesized cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.