Skip to content

Cell paths: foo.1 is not always equal to 1.foo #7498

@rgwood

Description

@rgwood

Describe the bug

image

How to reproduce

  1. Run [ { foo: "bar"}, { } ] | get foo.1, it returns Nothing
  2. Run [ { foo: "bar"}, { } ] | get 1.foo, it fails with a ShellError

Expected behavior

If a cell path has 2 members and one member is a number but the other is a column name, the order of those members should not matter. I'm not sure exactly what the behaviour should be here, but I do think it's desirable for the behaviour to be consistent.

I lean toward making both return a ShellError, but I'm not sure if there are some situations where that would be problematic (dealing with JSON files maybe?). Please chime in if you have an opinion or are aware of important scenarios we should be considering.

Screenshots

No response

Configuration

key value
version 0.72.2
branch main
commit_hash b7572f1
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.65.0 (897e37553 2022-11-02)
rust_channel 1.65.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.65.0 (4bc8f24d3 2022-10-20)
pkg_version 0.72.2
build_time 2022-12-07 16:34:42 -08:00
build_rust_channel debug
features database, default, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:type-systemProblems or features related to nushell's type systemsemanticsPlaces where we should define/clarify nushell's semantics

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions