mirror of
https://github.com/nushell/nushell
synced 2024-12-28 22:13:10 +00:00
6a274b860a
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. |
||
---|---|---|
.. | ||
custom_value.rs | ||
from.rs | ||
from_value.rs | ||
lazy_record.rs | ||
mod.rs | ||
range.rs | ||
stream.rs | ||
unit.rs |