mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 17:25:15 +02:00
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 👍
This commit is contained in:
@ -6,8 +6,8 @@ use nu_protocol::{
|
||||
Expression, Math, Operator, PathMember, PipelineElement, Redirection,
|
||||
},
|
||||
engine::{EngineState, Stack},
|
||||
IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Range, Record, ShellError, Span,
|
||||
Spanned, Unit, Value, VarId, ENV_VARIABLE_ID,
|
||||
report_error_new, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Range, Record,
|
||||
ShellError, Span, Spanned, Unit, Value, VarId, ENV_VARIABLE_ID,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@ -1127,6 +1127,20 @@ pub fn eval_variable(
|
||||
span: Span,
|
||||
) -> Result<Value, ShellError> {
|
||||
match var_id {
|
||||
// $nothing
|
||||
nu_protocol::NOTHING_VARIABLE_ID => {
|
||||
report_error_new(
|
||||
engine_state,
|
||||
&ShellError::GenericError(
|
||||
"Deprecated variable".into(),
|
||||
"`$nothing` is deprecated and will be removed in 0.87.".into(),
|
||||
Some(span),
|
||||
Some("Use `null` instead".into()),
|
||||
vec![],
|
||||
),
|
||||
);
|
||||
Ok(Value::nothing(span))
|
||||
}
|
||||
// $nu
|
||||
nu_protocol::NU_VARIABLE_ID => {
|
||||
if let Some(val) = engine_state.get_constant(var_id) {
|
||||
|
Reference in New Issue
Block a user