nushell/crates/nu-protocol/src/value
Reilly Wood 6a274b860a
Cell paths: make optional path members short-circuit (#8554)
This is a follow-up to https://github.com/nushell/nushell/pull/8379 and
https://github.com/nushell/nushell/discussions/8502.

This PR makes it so that the new `?` syntax for marking a path member as
optional short-circuits, as voted on in the
[8502](https://github.com/nushell/nushell/discussions/8502) poll.
Previously, `{ foo: 123 }.bar?.baz` would raise an error:

```
> { foo: 123 }.bar?.baz
  × Data cannot be accessed with a cell path
   ╭─[entry #15:1:1]
 1 │ { foo: 123 }.bar?.baz
   ·                   ─┬─
   ·                    ╰── nothing doesn't support cell paths
   ╰────
   ```

Here's what was happening:

1. The `bar?` path member access returns `nothing` because there is no field named `bar` on the record
2. The `baz` path member access fails when trying to access a `baz` field on that `nothing` value

After this change, `{ foo: 123 }.bar?.baz` returns `nothing`; the failed `bar?` access immediately returns `nothing` and the `baz` access never runs.
2023-03-23 09:54:19 +13:00
..
custom_value.rs Fix to json for SQLite databases (#8343) 2023-03-06 14:36:26 -08:00
from.rs Document and critically review ShellError variants - Ep. 3 (#8340) 2023-03-06 18:33:09 +01:00
from_value.rs Optional members in cell paths: Attempt 2 (#8379) 2023-03-15 20:50:58 -07:00
lazy_record.rs LazyRecord (#7619) 2023-01-18 19:27:26 -08:00
mod.rs Cell paths: make optional path members short-circuit (#8554) 2023-03-23 09:54:19 +13:00
range.rs Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
stream.rs Disable pipeline echo (#8292) 2023-03-17 11:53:46 +13:00
unit.rs Remove month and year duration constants (#6613) 2022-09-26 09:55:13 +13:00