forked from extern/nushell
nothing variable (#527)
* nothing variable * corrected comments * added color to nothing like bool * compare nothing with values * comparison tests
This commit is contained in:
@ -7,6 +7,7 @@ use std::fmt::{Display, Formatter, Result};
|
||||
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub enum FlatShape {
|
||||
Garbage,
|
||||
Nothing,
|
||||
Bool,
|
||||
Int,
|
||||
Float,
|
||||
@ -29,6 +30,7 @@ impl Display for FlatShape {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
FlatShape::Garbage => write!(f, "flatshape_garbage"),
|
||||
FlatShape::Nothing => write!(f, "flatshape_nothing"),
|
||||
FlatShape::Bool => write!(f, "flatshape_bool"),
|
||||
FlatShape::Int => write!(f, "flatshape_int"),
|
||||
FlatShape::Float => write!(f, "flatshape_float"),
|
||||
@ -127,6 +129,9 @@ pub fn flatten_expression(
|
||||
Expr::Garbage => {
|
||||
vec![(expr.span, FlatShape::Garbage)]
|
||||
}
|
||||
Expr::Nothing => {
|
||||
vec![(expr.span, FlatShape::Nothing)]
|
||||
}
|
||||
Expr::Int(_) => {
|
||||
vec![(expr.span, FlatShape::Int)]
|
||||
}
|
||||
|
@ -1186,6 +1186,16 @@ pub fn parse_variable_expr(
|
||||
},
|
||||
None,
|
||||
);
|
||||
} else if contents == b"$nothing" {
|
||||
return (
|
||||
Expression {
|
||||
expr: Expr::Nothing,
|
||||
span,
|
||||
ty: Type::Nothing,
|
||||
custom_completion: None,
|
||||
},
|
||||
None,
|
||||
);
|
||||
} else if contents == b"$nu" {
|
||||
return (
|
||||
Expression {
|
||||
@ -3483,6 +3493,7 @@ pub fn find_captures_in_expr(
|
||||
}
|
||||
Expr::ImportPattern(_) => {}
|
||||
Expr::Garbage => {}
|
||||
Expr::Nothing => {}
|
||||
Expr::GlobPattern(_) => {}
|
||||
Expr::Int(_) => {}
|
||||
Expr::Keyword(_, _, expr) => {
|
||||
|
@ -252,6 +252,8 @@ pub fn math_result_type(
|
||||
(Type::Filesize, Type::Filesize) => (Type::Bool, None),
|
||||
|
||||
(x, y) if x == y => (Type::Bool, None),
|
||||
(Type::Nothing, _) => (Type::Bool, None),
|
||||
(_, Type::Nothing) => (Type::Bool, None),
|
||||
(Type::Unknown, _) => (Type::Bool, None),
|
||||
(_, Type::Unknown) => (Type::Bool, None),
|
||||
_ => {
|
||||
@ -276,6 +278,8 @@ pub fn math_result_type(
|
||||
(Type::Duration, Type::Duration) => (Type::Bool, None),
|
||||
(Type::Filesize, Type::Filesize) => (Type::Bool, None),
|
||||
|
||||
(Type::Nothing, _) => (Type::Bool, None),
|
||||
(_, Type::Nothing) => (Type::Bool, None),
|
||||
(Type::Unknown, _) => (Type::Bool, None),
|
||||
(_, Type::Unknown) => (Type::Bool, None),
|
||||
_ => {
|
||||
|
Reference in New Issue
Block a user