mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Some fixes for the new evaluator
This commit is contained in:
parent
d5255f6dbf
commit
f44936ea5a
@ -426,6 +426,7 @@ crate fn find(obj: &Value, field: &str, op: &Operator, rhs: &Value) -> bool {
|
||||
|
||||
enum CompareValues {
|
||||
Ints(i64, i64),
|
||||
Floats(OF64, OF64),
|
||||
Bytes(i128, i128),
|
||||
String(String, String),
|
||||
}
|
||||
@ -434,6 +435,7 @@ impl CompareValues {
|
||||
fn compare(&self) -> std::cmp::Ordering {
|
||||
match self {
|
||||
CompareValues::Ints(left, right) => left.cmp(right),
|
||||
CompareValues::Floats(left, right) => left.cmp(right),
|
||||
CompareValues::Bytes(left, right) => left.cmp(right),
|
||||
CompareValues::String(left, right) => left.cmp(right),
|
||||
}
|
||||
@ -453,6 +455,8 @@ fn coerce_compare_primitive(left: &Primitive, right: &Primitive) -> Option<Compa
|
||||
|
||||
match (left, right) {
|
||||
(Int(left), Int(right)) => Some(CompareValues::Ints(*left, *right)),
|
||||
(Float(left), Int(right)) => Some(CompareValues::Floats(*left, (*right as f64).into())),
|
||||
(Int(left), Float(right)) => Some(CompareValues::Floats((*left as f64).into(), *right)),
|
||||
(Int(left), Bytes(right)) => Some(CompareValues::Bytes(*left as i128, *right as i128)),
|
||||
(Bytes(left), Int(right)) => Some(CompareValues::Bytes(*left as i128, *right as i128)),
|
||||
(String(left), String(right)) => Some(CompareValues::String(left.clone(), right.clone())),
|
||||
|
@ -17,6 +17,7 @@ Command: ParsedCommand = {
|
||||
Leaf: Expression = {
|
||||
<String> => Expression::Leaf(Leaf::String(<>)),
|
||||
<Num> => Expression::Leaf(Leaf::Int(<>)),
|
||||
<Size> => Expression::Leaf(Leaf::Int(<>)),
|
||||
<Variable> => Expression::VariableReference(<>),
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user