diff --git a/crates/nu-engine/src/evaluate/evaluator.rs b/crates/nu-engine/src/evaluate/evaluator.rs index 9272f39748..930b2ea0ad 100644 --- a/crates/nu-engine/src/evaluate/evaluator.rs +++ b/crates/nu-engine/src/evaluate/evaluator.rs @@ -253,6 +253,11 @@ fn evaluate_reference(name: &str, ctx: &EvaluationContext, tag: Tag) -> Result Ok(Value { + value: UntaggedValue::nothing(), + tag, + }), + x => match ctx.scope.get_var(x) { Some(v) => Ok(v), None => Err(ShellError::labeled_error( diff --git a/crates/nu-engine/tests/evaluate/invocation.rs b/crates/nu-engine/tests/evaluate/invocation.rs index cb695fd0c4..705ddea2c8 100644 --- a/crates/nu-engine/tests/evaluate/invocation.rs +++ b/crates/nu-engine/tests/evaluate/invocation.rs @@ -11,3 +11,26 @@ fn test_parse_invocation_with_range() { ); assert_eq!(actual.out, "[1,2,3]") } + +#[test] +fn create_nothing_in_table() { + let actual = nu!( + cwd: ".", + r#" + echo [[column]; [$nothing]] | to json + "# + ); + assert_eq!(actual.out, "{\"column\":null}"); +} + +#[test] +fn compare_to_nothing() { + let actual = nu!( + cwd: ".", + r#" + let f = $nothing + if $f == $nothing {echo $true} {echo $false} + "# + ); + assert_eq!(actual.out, "true"); +}