nushell/crates/nu-protocol/src/lib.rs
Antoine Stevan 6c026242d4
remove the $nothing variable (#10478)
related to 
- https://github.com/nushell/nushell/pull/9973
- https://github.com/nushell/nushell/pull/9918

thanks to @jntrnr and their super useful tips on this PR, i learned
about the parser + evaluation, so 🙏

# Description
because we already have `null` as the value of the type `nothing` and as
a followup to the two other attempts of mine, i propose to remove the
redundant `$nothing` built-in variable 😋

this PR is the first step, deprecating `$nothing`.
a followup PR will remove it altogether and wait for 0.87 👍 

⚙️ **details**: a new `NOTHING_VARIABLE_ID = 3` has been added,
parsing `$nothing` will create it, finally a `Value::Nothing` will be
produced and a warning will be reported.

this PR already fixes the `toolkit.nu` module so that it does not throw
a bunch of warnings each time 👌

# User-Facing Changes
`$nothing` is now deprecated and will be removed in 0.87
```nushell
> $nothing
Error:   × Deprecated variable
   ╭─[entry #1:1:1]
 1 │ $nothing
   · ────┬───
   ·     ╰── `$nothing` is deprecated and will be removed in 0.87.
   ╰────
  help: Use `null` instead
```

# Tests + Formatting
tests have been updated, especially
- `nothing_fails_string`
- `nothing_fails_int`
which use a variable called `nil` now to make sure `nothing` does not
support cell paths 👍

# After Submitting
classic deprecation mention 👍
2023-09-26 18:49:28 +02:00

48 lines
982 B
Rust

mod alias;
pub mod ast;
pub mod cli_error;
pub mod config;
mod did_you_mean;
pub mod engine;
pub mod eval_const;
mod example;
mod exportable;
mod id;
mod lev_distance;
mod module;
mod parse_error;
mod pipeline_data;
#[cfg(feature = "plugin")]
mod plugin_signature;
mod shell_error;
mod signature;
pub mod span;
mod syntax_shape;
mod ty;
pub mod util;
mod value;
mod variable;
pub use alias::*;
pub use cli_error::*;
pub use config::*;
pub use did_you_mean::did_you_mean;
pub use engine::{ENV_VARIABLE_ID, IN_VARIABLE_ID, NOTHING_VARIABLE_ID, NU_VARIABLE_ID};
pub use example::*;
pub use exportable::*;
pub use id::*;
pub use lev_distance::levenshtein_distance;
pub use module::*;
pub use parse_error::{DidYouMean, ParseError};
pub use pipeline_data::*;
#[cfg(feature = "plugin")]
pub use plugin_signature::*;
pub use shell_error::*;
pub use signature::*;
pub use span::*;
pub use syntax_shape::*;
pub use ty::*;
pub use util::BufferedReader;
pub use value::*;
pub use variable::*;