Browse Source

style(boa): clippy lints and cleanup of old todos (#1383)

- removes needless double references
- removes ignored tests/sections
pull/1431/head
neeldug 3 years ago committed by GitHub
parent
commit
aa507f3c50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      boa/src/builtins/array/mod.rs
  2. 14
      boa/src/builtins/array/tests.rs
  3. 2
      boa/src/builtins/bigint/mod.rs
  4. 2
      boa/src/builtins/date/mod.rs
  5. 2
      boa/src/builtins/function/mod.rs
  6. 2
      boa/src/builtins/number/mod.rs
  7. 2
      boa/src/builtins/string/mod.rs
  8. 3
      boa/src/builtins/string/tests.rs
  9. 2
      boa/src/builtins/symbol/mod.rs
  10. 8
      boa/src/environment/global_environment_record.rs
  11. 2
      boa/src/environment/object_environment_record.rs
  12. 6
      boa/src/object/gcobject.rs
  13. 10
      boa/src/object/internal_methods.rs
  14. 2
      boa/src/syntax/ast/node/conditional/if_node/mod.rs
  15. 2
      boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs
  16. 1
      boa/src/syntax/ast/node/iteration/mod.rs
  17. 4
      boa/src/syntax/ast/node/new/mod.rs
  18. 2
      boa/src/syntax/ast/node/object/mod.rs
  19. 2
      boa/src/syntax/ast/node/return_smt/mod.rs
  20. 6
      boa/src/syntax/lexer/string.rs
  21. 2
      boa/src/value/display.rs
  22. 4
      boa/src/value/mod.rs
  23. 11
      boa/src/value/operations.rs

8
boa/src/builtins/array/mod.rs

@ -1271,7 +1271,7 @@ impl Array {
let len = Self::flatten_into_array( let len = Self::flatten_into_array(
context, context,
&new_array, &new_array,
&this, this,
source_len, source_len,
0, 0,
depth, depth,
@ -1331,7 +1331,7 @@ impl Array {
if !mapper_function.is_undefined() { if !mapper_function.is_undefined() {
// 1. Set element to Call(mapperFunction, thisArg, <<element, sourceIndex, source>>) // 1. Set element to Call(mapperFunction, thisArg, <<element, sourceIndex, source>>)
let args = [element, Value::from(source_index), target.clone()]; let args = [element, Value::from(source_index), target.clone()];
element = context.call(&mapper_function, &this_arg, &args)?; element = context.call(mapper_function, this_arg, &args)?;
} }
let element_as_object = element.as_object(); let element_as_object = element.as_object();
@ -1689,7 +1689,7 @@ impl Array {
Value::from(k), Value::from(k),
this.clone(), this.clone(),
]; ];
accumulator = context.call(&callback, &Value::undefined(), &arguments)?; accumulator = context.call(callback, &Value::undefined(), &arguments)?;
/* We keep track of possibly shortened length in order to prevent unnecessary iteration. /* We keep track of possibly shortened length in order to prevent unnecessary iteration.
It may also be necessary to do this since shortening the array length does not It may also be necessary to do this since shortening the array length does not
delete array elements. See: https://github.com/boa-dev/boa/issues/557 */ delete array elements. See: https://github.com/boa-dev/boa/issues/557 */
@ -1770,7 +1770,7 @@ impl Array {
Value::from(k), Value::from(k),
this.clone(), this.clone(),
]; ];
accumulator = context.call(&callback, &Value::undefined(), &arguments)?; accumulator = context.call(callback, &Value::undefined(), &arguments)?;
/* We keep track of possibly shortened length in order to prevent unnecessary iteration. /* We keep track of possibly shortened length in order to prevent unnecessary iteration.
It may also be necessary to do this since shortening the array length does not It may also be necessary to do this since shortening the array length does not
delete array elements. See: https://github.com/boa-dev/boa/issues/557 */ delete array elements. See: https://github.com/boa-dev/boa/issues/557 */

14
boa/src/builtins/array/tests.rs

@ -767,12 +767,11 @@ fn map() {
var one = ["x"]; var one = ["x"];
var many = ["x", "y", "z"]; var many = ["x", "y", "z"];
// TODO: uncomment when `this` has been implemented var _this = { answer: 42 };
// var _this = { answer: 42 };
// function callbackThatUsesThis() { function callbackThatUsesThis() {
// return 'The answer to life is: ' + this.answer; return 'The answer to life is: ' + this.answer;
// } }
var empty_mapped = empty.map(v => v + '_'); var empty_mapped = empty.map(v => v + '_');
var one_mapped = one.map(v => '_' + v); var one_mapped = one.map(v => '_' + v);
@ -818,10 +817,9 @@ fn map() {
String::from("\"_x__y__z_\"") String::from("\"_x__y__z_\"")
); );
// TODO: uncomment when `this` has been implemented
// One but it uses `this` inside the callback // One but it uses `this` inside the callback
// let one_with_this = forward(&mut context, "one.map(callbackThatUsesThis, _this)[0];"); let one_with_this = forward(&mut context, "one.map(callbackThatUsesThis, _this)[0];");
// assert_eq!(one_with_this, String::from("The answer to life is: 42")) assert_eq!(one_with_this, String::from("\"The answer to life is: 42\""))
} }
#[test] #[test]

2
boa/src/builtins/bigint/mod.rs

@ -78,7 +78,7 @@ impl BigInt {
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt
fn constructor(_: &Value, args: &[Value], context: &mut Context) -> Result<Value> { fn constructor(_: &Value, args: &[Value], context: &mut Context) -> Result<Value> {
let data = match args.get(0) { let data = match args.get(0) {
Some(ref value) => value.to_bigint(context)?, Some(value) => value.to_bigint(context)?,
None => JsBigInt::zero(), None => JsBigInt::zero(),
}; };
Ok(Value::from(data)) Ok(Value::from(data))

2
boa/src/builtins/date/mod.rs

@ -444,7 +444,7 @@ impl Date {
let tv = match this_time_value(value, context) { let tv = match this_time_value(value, context) {
Ok(dt) => dt.0, Ok(dt) => dt.0,
_ => match value.to_primitive(context, PreferredType::Default)? { _ => match value.to_primitive(context, PreferredType::Default)? {
Value::String(ref str) => match chrono::DateTime::parse_from_rfc3339(&str) { Value::String(ref str) => match chrono::DateTime::parse_from_rfc3339(str) {
Ok(dt) => Some(dt.naive_utc()), Ok(dt) => Some(dt.naive_utc()),
_ => None, _ => None,
}, },

2
boa/src/builtins/function/mod.rs

@ -120,7 +120,7 @@ impl Function {
) { ) {
// Create array of values // Create array of values
let array = Array::new_array(context); let array = Array::new_array(context);
Array::add_to_array_object(&array, &args_list.get(index..).unwrap_or_default(), context) Array::add_to_array_object(&array, args_list.get(index..).unwrap_or_default(), context)
.unwrap(); .unwrap();
// Create binding // Create binding

2
boa/src/builtins/number/mod.rs

@ -160,7 +160,7 @@ impl Number {
context: &mut Context, context: &mut Context,
) -> Result<Value> { ) -> Result<Value> {
let data = match args.get(0) { let data = match args.get(0) {
Some(ref value) => value.to_numeric_number(context)?, Some(value) => value.to_numeric_number(context)?,
None => 0.0, None => 0.0,
}; };
if new_target.is_undefined() { if new_target.is_undefined() {

2
boa/src/builtins/string/mod.rs

@ -169,7 +169,7 @@ impl String {
.expect("'Symbol::to_string' returns 'Value::String'") .expect("'Symbol::to_string' returns 'Value::String'")
.clone() .clone()
} }
Some(ref value) => value.to_string(context)?, Some(value) => value.to_string(context)?,
None => JsString::default(), None => JsString::default(),
}; };

3
boa/src/builtins/string/tests.rs

@ -1,8 +1,6 @@
use crate::{forward, forward_val, Context}; use crate::{forward, forward_val, Context};
///TODO: re-enable when getProperty() is finished;
#[test] #[test]
#[ignore]
fn length() { fn length() {
//TEST262: https://github.com/tc39/test262/blob/master/test/built-ins/String/length.js //TEST262: https://github.com/tc39/test262/blob/master/test/built-ins/String/length.js
let mut context = Context::new(); let mut context = Context::new();
@ -16,7 +14,6 @@ fn length() {
let a = forward(&mut context, "a.length"); let a = forward(&mut context, "a.length");
assert_eq!(a, "1"); assert_eq!(a, "1");
let b = forward(&mut context, "b.length"); let b = forward(&mut context, "b.length");
// TODO: fix this
// unicode surrogate pair length should be 1 // unicode surrogate pair length should be 1
// utf16/usc2 length should be 2 // utf16/usc2 length should be 2
// utf8 length should be 4 // utf8 length should be 4

2
boa/src/builtins/symbol/mod.rs

@ -169,7 +169,7 @@ impl Symbol {
return context.throw_type_error("Symbol is not a constructor"); return context.throw_type_error("Symbol is not a constructor");
} }
let description = match args.get(0) { let description = match args.get(0) {
Some(ref value) if !value.is_undefined() => Some(value.to_string(context)?), Some(value) if !value.is_undefined() => Some(value.to_string(context)?),
_ => None, _ => None,
}; };

8
boa/src/environment/global_environment_record.rs

@ -185,7 +185,7 @@ impl EnvironmentRecordTrait for GlobalEnvironmentRecord {
} }
fn initialize_binding(&self, name: &str, value: Value, context: &mut Context) -> Result<()> { fn initialize_binding(&self, name: &str, value: Value, context: &mut Context) -> Result<()> {
if self.declarative_record.has_binding(&name) { if self.declarative_record.has_binding(name) {
return self return self
.declarative_record .declarative_record
.initialize_binding(name, value, context); .initialize_binding(name, value, context);
@ -205,7 +205,7 @@ impl EnvironmentRecordTrait for GlobalEnvironmentRecord {
strict: bool, strict: bool,
context: &mut Context, context: &mut Context,
) -> Result<()> { ) -> Result<()> {
if self.declarative_record.has_binding(&name) { if self.declarative_record.has_binding(name) {
return self return self
.declarative_record .declarative_record
.set_mutable_binding(name, value, strict, context); .set_mutable_binding(name, value, strict, context);
@ -215,7 +215,7 @@ impl EnvironmentRecordTrait for GlobalEnvironmentRecord {
} }
fn get_binding_value(&self, name: &str, strict: bool, context: &mut Context) -> Result<Value> { fn get_binding_value(&self, name: &str, strict: bool, context: &mut Context) -> Result<Value> {
if self.declarative_record.has_binding(&name) { if self.declarative_record.has_binding(name) {
return self return self
.declarative_record .declarative_record
.get_binding_value(name, strict, context); .get_binding_value(name, strict, context);
@ -224,7 +224,7 @@ impl EnvironmentRecordTrait for GlobalEnvironmentRecord {
} }
fn delete_binding(&self, name: &str) -> bool { fn delete_binding(&self, name: &str) -> bool {
if self.declarative_record.has_binding(&name) { if self.declarative_record.has_binding(name) {
return self.declarative_record.delete_binding(name); return self.declarative_record.delete_binding(name);
} }

2
boa/src/environment/object_environment_record.rs

@ -88,7 +88,7 @@ impl EnvironmentRecordTrait for ObjectEnvironmentRecord {
// We should never need to check if a binding has been created, // We should never need to check if a binding has been created,
// As all calls to create_mutable_binding are followed by initialized binding // As all calls to create_mutable_binding are followed by initialized binding
// The below is just a check. // The below is just a check.
debug_assert!(self.has_binding(&name)); debug_assert!(self.has_binding(name));
self.set_mutable_binding(name, value, false, context) self.set_mutable_binding(name, value, false, context)
} }

6
boa/src/object/gcobject.rs

@ -292,7 +292,7 @@ impl GcObject {
match body { match body {
FunctionBody::BuiltInConstructor(function) if construct => { FunctionBody::BuiltInConstructor(function) if construct => {
function(&this_target, args, context) function(this_target, args, context)
} }
FunctionBody::BuiltInConstructor(function) => { FunctionBody::BuiltInConstructor(function) => {
function(&Value::undefined(), args, context) function(&Value::undefined(), args, context)
@ -378,7 +378,7 @@ impl GcObject {
// a recursive structure // a recursive structure
// We can follow v8 & SpiderMonkey's lead and return a default value for the hint in this situation // We can follow v8 & SpiderMonkey's lead and return a default value for the hint in this situation
// (see https://repl.it/repls/IvoryCircularCertification#index.js) // (see https://repl.it/repls/IvoryCircularCertification#index.js)
let recursion_limiter = RecursionLimiter::new(&self); let recursion_limiter = RecursionLimiter::new(self);
if recursion_limiter.live { if recursion_limiter.live {
// we're in a recursive object, bail // we're in a recursive object, bail
return Ok(match hint { return Ok(match hint {
@ -1023,7 +1023,7 @@ impl RecursionLimiter {
impl Debug for GcObject { impl Debug for GcObject {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
let limiter = RecursionLimiter::new(&self); let limiter = RecursionLimiter::new(self);
// Typically, using `!limiter.live` would be good enough here. // Typically, using `!limiter.live` would be good enough here.
// However, the JS object hierarchy involves quite a bit of repitition, and the sheer amount of data makes // However, the JS object hierarchy involves quite a bit of repitition, and the sheer amount of data makes

10
boa/src/object/internal_methods.rs

@ -273,7 +273,7 @@ impl GcObject {
pub(crate) fn __delete__(&self, key: &PropertyKey) -> bool { pub(crate) fn __delete__(&self, key: &PropertyKey) -> bool {
match self.__get_own_property__(key) { match self.__get_own_property__(key) {
Some(desc) if desc.configurable() => { Some(desc) if desc.configurable() => {
self.remove(&key); self.remove(key);
true true
} }
Some(_) => false, Some(_) => false,
@ -458,13 +458,13 @@ impl GcObject {
// 8. // 8.
if !current.configurable() { if !current.configurable() {
if let (Some(current_get), Some(desc_get)) = (current.getter(), desc.getter()) { if let (Some(current_get), Some(desc_get)) = (current.getter(), desc.getter()) {
if !GcObject::equals(&current_get, &desc_get) { if !GcObject::equals(current_get, desc_get) {
return false; return false;
} }
} }
if let (Some(current_set), Some(desc_set)) = (current.setter(), desc.setter()) { if let (Some(current_set), Some(desc_set)) = (current.setter(), desc.setter()) {
if !GcObject::equals(&current_set, &desc_set) { if !GcObject::equals(current_set, desc_set) {
return false; return false;
} }
} }
@ -685,7 +685,7 @@ impl GcObject {
pub fn ordinary_get_own_property(&self, key: &PropertyKey) -> Option<PropertyDescriptor> { pub fn ordinary_get_own_property(&self, key: &PropertyKey) -> Option<PropertyDescriptor> {
let object = self.borrow(); let object = self.borrow();
let property = match key { let property = match key {
PropertyKey::Index(index) => object.indexed_properties.get(&index), PropertyKey::Index(index) => object.indexed_properties.get(index),
PropertyKey::String(ref st) => object.string_properties.get(st), PropertyKey::String(ref st) => object.string_properties.get(st),
PropertyKey::Symbol(ref symbol) => object.symbol_properties.get(symbol), PropertyKey::Symbol(ref symbol) => object.symbol_properties.get(symbol),
}; };
@ -939,7 +939,7 @@ impl Object {
#[inline] #[inline]
pub(crate) fn remove(&mut self, key: &PropertyKey) -> Option<PropertyDescriptor> { pub(crate) fn remove(&mut self, key: &PropertyKey) -> Option<PropertyDescriptor> {
match key { match key {
PropertyKey::Index(index) => self.indexed_properties.remove(&index), PropertyKey::Index(index) => self.indexed_properties.remove(index),
PropertyKey::String(ref string) => self.string_properties.remove(string), PropertyKey::String(ref string) => self.string_properties.remove(string),
PropertyKey::Symbol(ref symbol) => self.symbol_properties.remove(symbol), PropertyKey::Symbol(ref symbol) => self.symbol_properties.remove(symbol),
} }

2
boa/src/syntax/ast/node/conditional/if_node/mod.rs

@ -82,7 +82,7 @@ impl Executable for If {
fn run(&self, context: &mut Context) -> Result<Value> { fn run(&self, context: &mut Context) -> Result<Value> {
Ok(if self.cond().run(context)?.to_boolean() { Ok(if self.cond().run(context)?.to_boolean() {
self.body().run(context)? self.body().run(context)?
} else if let Some(ref else_e) = self.else_node() { } else if let Some(else_e) = self.else_node() {
else_e.run(context)? else_e.run(context)?
} else { } else {
Value::undefined() Value::undefined()

2
boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs

@ -50,7 +50,7 @@ impl ArrowFunctionDecl {
/// Gets the body of the arrow function. /// Gets the body of the arrow function.
pub(crate) fn body(&self) -> &[Node] { pub(crate) fn body(&self) -> &[Node] {
&self.body.items() self.body.items()
} }
/// Implements the display formatting with indentation. /// Implements the display formatting with indentation.

1
boa/src/syntax/ast/node/iteration/mod.rs

@ -9,7 +9,6 @@ pub use self::{
mod tests; mod tests;
// Checking labels for break and continue is the same operation for `ForLoop`, `While` and `DoWhile` // Checking labels for break and continue is the same operation for `ForLoop`, `While` and `DoWhile`
#[macro_use]
macro_rules! handle_state_with_labels { macro_rules! handle_state_with_labels {
($self:ident, $label:ident, $interpreter:ident, $state:tt) => {{ ($self:ident, $label:ident, $interpreter:ident, $state:tt) => {{
if let Some(brk_label) = $label { if let Some(brk_label) = $label {

4
boa/src/syntax/ast/node/new/mod.rs

@ -38,12 +38,12 @@ pub struct New {
impl New { impl New {
/// Gets the name of the function call. /// Gets the name of the function call.
pub fn expr(&self) -> &Node { pub fn expr(&self) -> &Node {
&self.call.expr() self.call.expr()
} }
/// Retrieves the arguments passed to the function. /// Retrieves the arguments passed to the function.
pub fn args(&self) -> &[Node] { pub fn args(&self) -> &[Node] {
&self.call.args() self.call.args()
} }
} }

2
boa/src/syntax/ast/node/object/mod.rs

@ -75,7 +75,7 @@ impl Object {
MethodDefinitionKind::Ordinary => (), MethodDefinitionKind::Ordinary => (),
} }
write!(f, "{}(", key)?; write!(f, "{}(", key)?;
join_nodes(f, &node.parameters())?; join_nodes(f, node.parameters())?;
write!(f, ") ")?; write!(f, ") ")?;
node.display_block(f, indent + 1)?; node.display_block(f, indent + 1)?;
writeln!(f, ",")?; writeln!(f, ",")?;

2
boa/src/syntax/ast/node/return_smt/mod.rs

@ -63,7 +63,7 @@ impl Return {
impl Executable for Return { impl Executable for Return {
fn run(&self, context: &mut Context) -> Result<Value> { fn run(&self, context: &mut Context) -> Result<Value> {
let result = match self.expr() { let result = match self.expr() {
Some(ref v) => v.run(context), Some(v) => v.run(context),
None => Ok(Value::undefined()), None => Ok(Value::undefined()),
}; };
// Set flag for return // Set flag for return

6
boa/src/syntax/lexer/string.rs

@ -257,7 +257,7 @@ impl StringLiteral {
.ok() .ok()
.and_then(|code_point_str| { .and_then(|code_point_str| {
// The `code_point_str` should represent a single unicode codepoint, convert to u32 // The `code_point_str` should represent a single unicode codepoint, convert to u32
u32::from_str_radix(&code_point_str, 16).ok() u32::from_str_radix(code_point_str, 16).ok()
}) })
.ok_or_else(|| { .ok_or_else(|| {
Error::syntax("malformed Unicode character escape sequence", start_pos) Error::syntax("malformed Unicode character escape sequence", start_pos)
@ -281,7 +281,7 @@ impl StringLiteral {
// Convert to u16 // Convert to u16
let code_point = str::from_utf8(&code_point_utf8_bytes) let code_point = str::from_utf8(&code_point_utf8_bytes)
.ok() .ok()
.and_then(|code_point_str| u16::from_str_radix(&code_point_str, 16).ok()) .and_then(|code_point_str| u16::from_str_radix(code_point_str, 16).ok())
.ok_or_else(|| Error::syntax("invalid Unicode escape sequence", start_pos))?; .ok_or_else(|| Error::syntax("invalid Unicode escape sequence", start_pos))?;
Ok(code_point as u32) Ok(code_point as u32)
@ -300,7 +300,7 @@ impl StringLiteral {
cursor.fill_bytes(&mut code_point_utf8_bytes)?; cursor.fill_bytes(&mut code_point_utf8_bytes)?;
let code_point = str::from_utf8(&code_point_utf8_bytes) let code_point = str::from_utf8(&code_point_utf8_bytes)
.ok() .ok()
.and_then(|code_point_str| u16::from_str_radix(&code_point_str, 16).ok()) .and_then(|code_point_str| u16::from_str_radix(code_point_str, 16).ok())
.ok_or_else(|| Error::syntax("invalid Hexadecimal escape sequence", start_pos))?; .ok_or_else(|| Error::syntax("invalid Hexadecimal escape sequence", start_pos))?;
Ok(code_point as u32) Ok(code_point as u32)

2
boa/src/value/display.rs

@ -178,7 +178,7 @@ pub(crate) fn log_string_from(x: &Value, print_internals: bool, print_children:
format!("Set({})", size) format!("Set({})", size)
} }
} }
_ => display_obj(&x, print_internals), _ => display_obj(x, print_internals),
} }
} }
Value::Symbol(ref symbol) => symbol.to_string(), Value::Symbol(ref symbol) => symbol.to_string(),

4
boa/src/value/mod.rs

@ -564,7 +564,7 @@ impl Value {
PreferredType::Default => "default", PreferredType::Default => "default",
} }
.into(); .into();
let result = exotic_to_prim.call(&self, &[hint], context)?; let result = exotic_to_prim.call(self, &[hint], context)?;
return if result.is_object() { return if result.is_object() {
Err(context.construct_type_error("Symbol.toPrimitive cannot return an object")) Err(context.construct_type_error("Symbol.toPrimitive cannot return an object"))
} else { } else {
@ -897,7 +897,7 @@ impl Value {
/// See: <https://tc39.es/ecma262/#sec-tonumeric> /// See: <https://tc39.es/ecma262/#sec-tonumeric>
pub fn to_numeric_number(&self, context: &mut Context) -> Result<f64> { pub fn to_numeric_number(&self, context: &mut Context) -> Result<f64> {
let primitive = self.to_primitive(context, PreferredType::Number)?; let primitive = self.to_primitive(context, PreferredType::Number)?;
if let Some(ref bigint) = primitive.as_bigint() { if let Some(bigint) = primitive.as_bigint() {
return Ok(bigint.to_f64()); return Ok(bigint.to_f64());
} }
primitive.to_number(context) primitive.to_number(context)

11
boa/src/value/operations.rs

@ -11,9 +11,12 @@ impl Value {
(Self::Integer(x), Self::Rational(y)) => Self::rational(f64::from(*x) + y), (Self::Integer(x), Self::Rational(y)) => Self::rational(f64::from(*x) + y),
(Self::Rational(x), Self::Integer(y)) => Self::rational(x + f64::from(*y)), (Self::Rational(x), Self::Integer(y)) => Self::rational(x + f64::from(*y)),
(Self::String(ref x), Self::String(ref y)) => Self::string(format!("{}{}", x, y)),
(Self::String(ref x), y) => Self::string(format!("{}{}", x, y.to_string(context)?)),
(x, Self::String(ref y)) => Self::string(format!("{}{}", x.to_string(context)?, y)),
(Self::String(ref x), Self::String(ref y)) => Self::from(JsString::concat(x, y)), (Self::String(ref x), Self::String(ref y)) => Self::from(JsString::concat(x, y)),
(Self::String(ref x), ref y) => Self::from(JsString::concat(x, y.to_string(context)?)), (Self::String(ref x), y) => Self::from(JsString::concat(x, y.to_string(context)?)),
(ref x, Self::String(ref y)) => Self::from(JsString::concat(x.to_string(context)?, y)), (x, Self::String(ref y)) => Self::from(JsString::concat(x.to_string(context)?, y)),
(Self::BigInt(ref n1), Self::BigInt(ref n2)) => { (Self::BigInt(ref n1), Self::BigInt(ref n2)) => {
Self::bigint(n1.as_inner().clone() + n2.as_inner().clone()) Self::bigint(n1.as_inner().clone() + n2.as_inner().clone())
} }
@ -487,14 +490,14 @@ impl Value {
unreachable!() unreachable!()
} }
(Self::BigInt(ref x), Self::String(ref y)) => { (Self::BigInt(ref x), Self::String(ref y)) => {
if let Some(y) = JsBigInt::from_string(&y) { if let Some(y) = JsBigInt::from_string(y) {
(*x < y).into() (*x < y).into()
} else { } else {
AbstractRelation::Undefined AbstractRelation::Undefined
} }
} }
(Self::String(ref x), Self::BigInt(ref y)) => { (Self::String(ref x), Self::BigInt(ref y)) => {
if let Some(x) = JsBigInt::from_string(&x) { if let Some(x) = JsBigInt::from_string(x) {
(x < *y).into() (x < *y).into()
} else { } else {
AbstractRelation::Undefined AbstractRelation::Undefined

Loading…
Cancel
Save