nushell
nushell copied to clipboard
let binding an existing variable to an invalid object drops the previous binding
Describe the bug
When an invalid value is let
bound to an existing variable an error occurs as expected, but the previous variable binding is dropped.
Note that declaring a mutable binding let mut foo = "good value"
and re-assigning that value directly with $foo = bad_value
does keep the previous binding after triggering an error
How to reproduce
~> let foo = "valid string" 02/07/2024 11:04:50 PM
~> $foo 02/07/2024 11:04:57 PM
valid string
~> let foo = invalid_string 02/07/2024 11:05:05 PM
Error: nu::shell::external_command
× External command failed
╭─[entry #6:1:1]
1 │ let foo = invalid_string
· ───────┬──────
· ╰── executable was not found
╰────
help: No such file or directory (os error 2)
~> $foo 02/07/2024 11:05:09 PM
Error: nu::shell::variable_not_found
× Variable not found
╭─[entry #7:1:1]
1 │ $foo
· ──┬─
· ╰── variable not found
╰────
Expected behavior
The variable foo is still accessible as $foo with a value of "valid string"
Screenshots
No response
Configuration
key | value |
---|---|
version | 0.89.1 |
branch | main |
commit_hash | 4458aae3d41517d74ce1507ad3e8cd94021feb16 |
build_os | linux-x86_64 |
build_target | x86_64-unknown-linux-gnu |
rust_version | rustc 1.73.0 (cc66ad468 2023-10-03) |
rust_channel | 1.73.0-x86_64-unknown-linux-gnu |
cargo_version | cargo 1.73.0 (9c4383fb5 2023-08-26) |
build_time | 2024-01-20 22:17:23 -05:00 |
build_rust_channel | release |
allocator | mimalloc |
features | dataframe, default, sqlite, trash, which, zip |
installed_plugins | port list |
Additional context
https://discord.com/channels/601130461678272522/614593951969574961/1205000221571031050