diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 0419aa14ea..567b456653 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -440,19 +440,19 @@ pub fn eval_expression( } Operator::BitOr => { let rhs = eval_expression(engine_state, stack, rhs)?; - lhs.bor(op_span, &rhs, expr.span) + lhs.bit_or(op_span, &rhs, expr.span) } Operator::BitAnd => { let rhs = eval_expression(engine_state, stack, rhs)?; - lhs.band(op_span, &rhs, expr.span) + lhs.bit_and(op_span, &rhs, expr.span) } Operator::ShiftRight => { let rhs = eval_expression(engine_state, stack, rhs)?; - lhs.bshr(op_span, &rhs, expr.span) + lhs.bit_shr(op_span, &rhs, expr.span) } Operator::ShiftLeft => { let rhs = eval_expression(engine_state, stack, rhs)?; - lhs.bshl(op_span, &rhs, expr.span) + lhs.bit_shl(op_span, &rhs, expr.span) } } } diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 52173d6c88..4daa5075f3 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -4106,10 +4106,10 @@ pub fn parse_operator( b"in" => Operator::In, b"not-in" => Operator::NotIn, b"mod" => Operator::Modulo, - b"bor" => Operator::BitOr, - b"band" => Operator::BitAnd, - b"bshl" => Operator::ShiftLeft, - b"bshr" => Operator::ShiftRight, + b"bit-or" => Operator::BitOr, + b"bit-and" => Operator::BitAnd, + b"bit-shl" => Operator::ShiftLeft, + b"bit-shr" => Operator::ShiftRight, b"starts-with" => Operator::StartsWith, b"ends-with" => Operator::EndsWith, b"&&" | b"and" => Operator::And, diff --git a/crates/nu-protocol/src/ast/operator.rs b/crates/nu-protocol/src/ast/operator.rs index ccf5a5e9cb..a6a8383222 100644 --- a/crates/nu-protocol/src/ast/operator.rs +++ b/crates/nu-protocol/src/ast/operator.rs @@ -52,10 +52,10 @@ impl Display for Operator { Operator::And => write!(f, "&&"), Operator::Or => write!(f, "||"), Operator::Pow => write!(f, "**"), - Operator::BitOr => write!(f, "bor"), - Operator::BitAnd => write!(f, "band"), - Operator::ShiftLeft => write!(f, "bshl"), - Operator::ShiftRight => write!(f, "bshr"), + Operator::BitOr => write!(f, "bit-or"), + Operator::BitAnd => write!(f, "bit-and"), + Operator::ShiftLeft => write!(f, "bit-shl"), + Operator::ShiftRight => write!(f, "bit-shr"), Operator::LessThanOrEqual => write!(f, "<="), Operator::GreaterThanOrEqual => write!(f, ">="), Operator::StartsWith => write!(f, "starts-with"), diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 6a619ebab6..7b663b21e6 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -2240,7 +2240,7 @@ impl Value { } } - pub fn bshl(&self, op: Span, rhs: &Value, span: Span) -> Result { + pub fn bit_shl(&self, op: Span, rhs: &Value, span: Span) -> Result { match (self, rhs) { (Value::Int { val: lhs, .. }, Value::Int { val: rhs, .. }) => Ok(Value::Int { span, @@ -2259,7 +2259,7 @@ impl Value { } } - pub fn bshr(&self, op: Span, rhs: &Value, span: Span) -> Result { + pub fn bit_shr(&self, op: Span, rhs: &Value, span: Span) -> Result { match (self, rhs) { (Value::Int { val: lhs, .. }, Value::Int { val: rhs, .. }) => Ok(Value::Int { span, @@ -2278,7 +2278,7 @@ impl Value { } } - pub fn bor(&self, op: Span, rhs: &Value, span: Span) -> Result { + pub fn bit_or(&self, op: Span, rhs: &Value, span: Span) -> Result { match (self, rhs) { (Value::Int { val: lhs, .. }, Value::Int { val: rhs, .. }) => Ok(Value::Int { span, @@ -2297,7 +2297,7 @@ impl Value { } } - pub fn band(&self, op: Span, rhs: &Value, span: Span) -> Result { + pub fn bit_and(&self, op: Span, rhs: &Value, span: Span) -> Result { match (self, rhs) { (Value::Int { val: lhs, .. }, Value::Int { val: rhs, .. }) => Ok(Value::Int { span, diff --git a/src/tests/test_math.rs b/src/tests/test_math.rs index 86793f31d1..f9219f4d91 100644 --- a/src/tests/test_math.rs +++ b/src/tests/test_math.rs @@ -26,23 +26,23 @@ fn modulo2() -> TestResult { } #[test] -fn bshr() -> TestResult { - run_test("16 bshr 1", "8") +fn bit_shr() -> TestResult { + run_test("16 bit-shr 1", "8") } #[test] -fn bshl() -> TestResult { - run_test("5 bshl 1", "10") +fn bit_shl() -> TestResult { + run_test("5 bit-shl 1", "10") } #[test] -fn bshl_add() -> TestResult { - run_test("2 bshl 1 + 2", "16") +fn bit_shl_add() -> TestResult { + run_test("2 bit-shl 1 + 2", "16") } #[test] -fn sub_bshr() -> TestResult { - run_test("10 - 2 bshr 2", "2") +fn sub_bit_shr() -> TestResult { + run_test("10 - 2 bit-shr 2", "2") } #[test] @@ -56,18 +56,18 @@ fn or() -> TestResult { } #[test] -fn band() -> TestResult { - run_test("2 band 4", "0") +fn bit_and() -> TestResult { + run_test("2 bit-and 4", "0") } #[test] -fn bor() -> TestResult { - run_test("2 bor 4", "6") +fn bit_or() -> TestResult { + run_test("2 bit-or 4", "6") } #[test] fn bit_and_or() -> TestResult { - run_test("2 bor 4 band 1 + 2", "2") + run_test("2 bit-or 4 bit-and 1 + 2", "2") } #[test]