diff --git a/crates/nu-cli/src/completions/variable_completions.rs b/crates/nu-cli/src/completions/variable_completions.rs index 650d87fc6..ab755d1d8 100644 --- a/crates/nu-cli/src/completions/variable_completions.rs +++ b/crates/nu-cli/src/completions/variable_completions.rs @@ -43,7 +43,7 @@ impl Completer for VariableCompletion { options: &CompletionOptions, ) -> Vec { let mut output = vec![]; - let builtins = ["$nu", "$in", "$env", "$nothing"]; + let builtins = ["$nu", "$in", "$env"]; let var_str = std::str::from_utf8(&self.var_context.0) .unwrap_or("") .to_lowercase(); diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 92b871d9c..f3af6bfcd 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -6,8 +6,8 @@ use nu_protocol::{ Expression, Math, Operator, PathMember, PipelineElement, Redirection, }, engine::{EngineState, Stack}, - report_error_new, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Range, Record, - ShellError, Span, Spanned, Unit, Value, VarId, ENV_VARIABLE_ID, + IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Range, Record, ShellError, Span, + Spanned, Unit, Value, VarId, ENV_VARIABLE_ID, }; use std::collections::HashMap; @@ -1128,20 +1128,6 @@ pub fn eval_variable( span: Span, ) -> Result { 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) { diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index 619625846..267938f6a 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -3043,7 +3043,7 @@ pub fn parse_let(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline .trim_start_matches('$') .to_string(); - if ["in", "nu", "env", "nothing"].contains(&var_name.as_str()) { + if ["in", "nu", "env"].contains(&var_name.as_str()) { working_set.error(ParseError::NameIsBuiltinVar(var_name, lvalue.span)) } @@ -3151,7 +3151,7 @@ pub fn parse_const(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipelin .to_string(); // TODO: Remove the hard-coded variables, too error-prone - if ["in", "nu", "env", "nothing"].contains(&var_name.as_str()) { + if ["in", "nu", "env"].contains(&var_name.as_str()) { working_set.error(ParseError::NameIsBuiltinVar(var_name, lvalue.span)) } @@ -3292,7 +3292,7 @@ pub fn parse_mut(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline .trim_start_matches('$') .to_string(); - if ["in", "nu", "env", "nothing"].contains(&var_name.as_str()) { + if ["in", "nu", "env"].contains(&var_name.as_str()) { working_set.error(ParseError::NameIsBuiltinVar(var_name, lvalue.span)) } diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 010db7201..8b002f3a0 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -18,7 +18,7 @@ use nu_protocol::{ engine::StateWorkingSet, eval_const::{eval_constant, value_as_string}, span, BlockId, DidYouMean, Flag, ParseError, PositionalArg, Signature, Span, Spanned, - SyntaxShape, Type, Unit, VarId, IN_VARIABLE_ID, NOTHING_VARIABLE_ID, + SyntaxShape, Type, Unit, VarId, ENV_VARIABLE_ID, IN_VARIABLE_ID, }; use crate::parse_keywords::{ @@ -1784,14 +1784,7 @@ pub fn parse_string_interpolation(working_set: &mut StateWorkingSet, span: Span) pub fn parse_variable_expr(working_set: &mut StateWorkingSet, span: Span) -> Expression { let contents = working_set.get_span_contents(span); - if contents == b"$nothing" { - return Expression { - expr: Expr::Var(nu_protocol::NOTHING_VARIABLE_ID), - span, - ty: Type::Nothing, - custom_completion: None, - }; - } else if contents == b"$nu" { + if contents == b"$nu" { return Expression { expr: Expr::Var(nu_protocol::NU_VARIABLE_ID), span, @@ -5834,9 +5827,7 @@ pub fn discover_captures_in_expr( discover_captures_in_expr(working_set, expr, seen, seen_blocks, output)?; } Expr::Var(var_id) => { - if (*var_id > NOTHING_VARIABLE_ID || *var_id == IN_VARIABLE_ID) - && !seen.contains(var_id) - { + if (*var_id > ENV_VARIABLE_ID || *var_id == IN_VARIABLE_ID) && !seen.contains(var_id) { output.push((*var_id, expr.span)); } } diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index 41b8bda67..952aec11c 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -113,7 +113,6 @@ const REGEX_CACHE_SIZE: usize = 100; // must be nonzero, otherwise will panic pub const NU_VARIABLE_ID: usize = 0; pub const IN_VARIABLE_ID: usize = 1; pub const ENV_VARIABLE_ID: usize = 2; -pub const NOTHING_VARIABLE_ID: usize = 3; // NOTE: If you add more to this list, make sure to update the > checks based on the last in the list impl EngineState { diff --git a/crates/nu-protocol/src/lib.rs b/crates/nu-protocol/src/lib.rs index 2cf80de21..854f5aa30 100644 --- a/crates/nu-protocol/src/lib.rs +++ b/crates/nu-protocol/src/lib.rs @@ -27,7 +27,7 @@ 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 engine::{ENV_VARIABLE_ID, IN_VARIABLE_ID, NU_VARIABLE_ID}; pub use example::*; pub use exportable::*; pub use id::*;