Repository: denoland/deno_core
Pull request #74 (2023-07-22 21:16:07)

chore: release v0.196.0
Sadly the release script is still not working correctly:

```
remote: error: GH006: Protected branch update failed for refs/heads/main.        
remote: error: 4 of 4 required status checks are expected.        
To https://github.com/denoland/deno_core
 ! [remote rejected] HEAD -> main (protected branch hook declined)
error: failed to push some refs to 'https://github.com/denoland/deno_core'
error: Uncaught (in promise) Error: Exited with code: 1
          throw new Error(`Exited with code: ${code}`);
                ^
    at CommandChild.pipedStdoutBuffer (https://deno.land/x/dax@0.30.0/src/command.ts:585:17)
    at eventLoopTick (ext:core/01_core.js:183:11)
```


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 7780259..74f1061 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -289,7 +289,7 @@ dependencies = [
 
 [[package]]
 name = "deno_core"
-version = "0.195.0"
+version = "0.196.0"
 dependencies = [
  "anyhow",
  "bencher",
@@ -327,7 +327,7 @@ dependencies = [
 
 [[package]]
 name = "deno_ops"
-version = "0.73.0"
+version = "0.74.0"
 dependencies = [
  "deno-proc-macro-rules",
  "lazy-regex",
@@ -1268,7 +1268,7 @@ dependencies = [
 
 [[package]]
 name = "serde_v8"
-version = "0.106.0"
+version = "0.107.0"
 dependencies = [
  "bencher",
  "bytes",
@@ -2042,9 +2042,9 @@ dependencies = [
 
 [[package]]
 name = "v8"
-version = "0.74.2"
+version = "0.74.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7568bf38565bd5b350d96abbf3d09417e8c9dd74fbb38860e91b759e46f9009c"
+checksum = "2eedac634b8dd39b889c5b62349cbc55913780226239166435c5cf66771792ea"
 dependencies = [
  "bitflags 1.3.2",
  "fslock",
diff --git a/Cargo.toml b/Cargo.toml
index 4b58109..e7c0c00 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,12 +16,12 @@ license = "MIT"
 repository = "https://github.com/denoland/deno"
 
 [workspace.dependencies]
-v8 = { version = "0.74.2", default-features = false }
+v8 = { version = "0.74.3", default-features = false }
 deno_ast = { version = "0.27.0", features = ["transpiling"] }
 
-deno_core = { version = "0.195.0", path = "./core" }
-deno_ops = { version = "0.73.0", path = "./ops" }
-serde_v8 = { version = "0.106.0", path = "./serde_v8" }
+deno_core = { version = "0.196.0", path = "./core" }
+deno_ops = { version = "0.74.0", path = "./ops" }
+serde_v8 = { version = "0.107.0", path = "./serde_v8" }
 
 anyhow = "1.0.57"
 bencher = "0.1"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index e89ef11..9c0956b 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "deno_core"
-version = "0.195.0"
+version = "0.196.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
diff --git a/ops/Cargo.toml b/ops/Cargo.toml
index 8822bd0..a8d247a 100644
--- a/ops/Cargo.toml
+++ b/ops/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "deno_ops"
-version = "0.73.0"
+version = "0.74.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
diff --git a/serde_v8/Cargo.toml b/serde_v8/Cargo.toml
index d74a118..0acd639 100644
--- a/serde_v8/Cargo.toml
+++ b/serde_v8/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "serde_v8"
-version = "0.106.0"
+version = "0.107.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
diff --git a/serde_v8/de.rs b/serde_v8/de.rs
index eb07271..228e2e5 100644
--- a/serde_v8/de.rs
+++ b/serde_v8/de.rs
@@ -4,7 +4,6 @@ use serde::de::Visitor;
 use serde::de::{self};
 use serde::Deserialize;
 
-use crate::error::value_to_type_str;
 use crate::error::Error;
 use crate::error::Result;
 use crate::keys::v8_struct_key;
@@ -81,7 +80,7 @@ macro_rules! deserialize_signed {
         } else if let Ok(x) = v8::Local::<v8::BigInt>::try_from(self.input) {
           x.i64_value().0 as $t
         } else {
-          return Err(Error::ExpectedInteger(value_to_type_str(self.input)));
+          return Err(Error::ExpectedInteger(self.input.type_repr()));
         },
       )
     }
@@ -100,7 +99,7 @@ macro_rules! deserialize_unsigned {
         } else if let Ok(x) = v8::Local::<v8::BigInt>::try_from(self.input) {
           x.u64_value().0 as $t
         } else {
-          return Err(Error::ExpectedInteger(value_to_type_str(self.input)));
+          return Err(Error::ExpectedInteger(self.input.type_repr()));
         },
       )
     }
@@ -177,7 +176,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
       } else if let Ok(x) = v8::Local::<v8::BigInt>::try_from(self.input) {
         bigint_to_f64(x)
       } else {
-        return Err(Error::ExpectedNumber(value_to_type_str(self.input)));
+        return Err(Error::ExpectedNumber(self.input.type_repr()));
       },
     )
   }
@@ -205,7 +204,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
       let string = to_utf8(v8_string, self.scope);
       visitor.visit_string(string)
     } else {
-      Err(Error::ExpectedString(value_to_type_str(self.input)))
+      Err(Error::ExpectedString(self.input.type_repr()))
     }
   }
 
@@ -257,7 +256,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
     V: Visitor<'de>,
   {
     let arr = v8::Local::<v8::Array>::try_from(self.input)
-      .map_err(|_| Error::ExpectedArray(value_to_type_str(self.input)))?;
+      .map_err(|_| Error::ExpectedArray(self.input.type_repr()))?;
     visitor.visit_seq(SeqAccess::new(arr.into(), self.scope, 0..arr.length()))
   }
 
@@ -297,7 +296,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
   {
     // Assume object, then get_own_property_names
     let obj = v8::Local::<v8::Object>::try_from(self.input)
-      .map_err(|_| Error::ExpectedObject(value_to_type_str(self.input)))?;
+      .map_err(|_| Error::ExpectedObject(self.input.type_repr()))?;
 
     if v8::Local::<v8::Map>::try_from(self.input).is_ok() {
       let pairs_array = v8::Local::<v8::Map>::try_from(self.input)
@@ -352,7 +351,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
       _ => {
         // Regular struct
         let obj = v8::Local::<v8::Object>::try_from(self.input)
-          .map_err(|_| Error::ExpectedObject(value_to_type_str(self.input)))?;
+          .map_err(|_| Error::ExpectedObject(self.input.type_repr()))?;
 
         // Fields names are a hint and must be inferred when not provided
         if fields.is_empty() {
@@ -399,7 +398,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
         let prop_names =
           obj.get_own_property_names(self.scope, Default::default());
         let prop_names = prop_names
-          .ok_or_else(|| Error::ExpectedEnum(value_to_type_str(self.input)))?;
+          .ok_or_else(|| Error::ExpectedEnum(self.input.type_repr()))?;
         let prop_names_len = prop_names.length();
         if prop_names_len != 1 {
           return Err(Error::LengthMismatch(prop_names_len as usize, 1));
@@ -414,7 +413,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
         payload,
       })
     } else {
-      Err(Error::ExpectedEnum(value_to_type_str(self.input)))
+      Err(Error::ExpectedEnum(self.input.type_repr()))
     }
   }
 
diff --git a/serde_v8/error.rs b/serde_v8/error.rs
index 16d7882..f1526b1 100644
--- a/serde_v8/error.rs
+++ b/serde_v8/error.rs
@@ -71,89 +71,3 @@ impl serde::de::Error for Error {
     Error::Message(msg.to_string())
   }
 }
-
-pub(crate) fn value_to_type_str(value: v8::Local<v8::Value>) -> &'static str {
-  if value.is_module_namespace_object() {
-    "Module"
-  } else if value.is_wasm_module_object() {
-    "WASM module"
-  } else if value.is_wasm_memory_object() {
-    "WASM memory object"
-  } else if value.is_proxy() {
-    "Proxy"
-  } else if value.is_shared_array_buffer() {
-    "SharedArrayBuffer"
-  } else if value.is_data_view() {
-    "DataView"
-  } else if value.is_big_uint64_array() {
-    "BigUint64Array"
-  } else if value.is_big_int64_array() {
-    "BigInt64Array"
-  } else if value.is_float64_array() {
-    "Float64Array"
-  } else if value.is_float32_array() {
-    "Float32Array"
-  } else if value.is_int32_array() {
-    "Int32Array"
-  } else if value.is_uint32_array() {
-    "Uint32Array"
-  } else if value.is_int16_array() {
-    "Int16Array"
-  } else if value.is_uint16_array() {
-    "Uint16Array"
-  } else if value.is_int8_array() {
-    "Int8Array"
-  } else if value.is_uint8_clamped_array() {
-    "Uint8ClampedArray"
-  } else if value.is_uint8_array() {
-    "Uint8Array"
-  } else if value.is_typed_array() {
-    "TypedArray"
-  } else if value.is_array_buffer_view() {
-    "ArrayBufferView"
-  } else if value.is_array_buffer() {
-    "ArrayBuffer"
-  } else if value.is_weak_set() {
-    "WeakSet"
-  } else if value.is_weak_map() {
-    "WeakMap"
-  } else if value.is_set_iterator() {
-    "Set Iterator"
-  } else if value.is_map_iterator() {
-    "Map Iterator"
-  } else if value.is_set() {
-    "Set"
-  } else if value.is_map() {
-    "Map"
-  } else if value.is_promise() {
-    "Promise"
-  } else if value.is_generator_function() {
-    "Generator function"
-  } else if value.is_async_function() {
-    "Async function"
-  } else if value.is_reg_exp() {
-    "RegExp"
-  } else if value.is_date() {
-    "Date"
-  } else if value.is_number() {
-    "Number"
-  } else if value.is_boolean() {
-    "Boolean"
-  } else if value.is_big_int() {
-    "bigint"
-  } else if value.is_array() {
-    "array"
-  } else if value.is_function() {
-    "function"
-  } else if value.is_symbol() {
-    "symbol"
-  } else if value.is_string() {
-    "string"
-  } else if value.is_null() {
-    "null"
-  } else if value.is_undefined() {
-    "undefined"
-  } else {
-    "unknown"
-  }
-}
diff --git a/serde_v8/magic/bigint.rs b/serde_v8/magic/bigint.rs
index 330803d..53fd538 100644
--- a/serde_v8/magic/bigint.rs
+++ b/serde_v8/magic/bigint.rs
@@ -5,7 +5,6 @@ use smallvec::SmallVec;
 
 use super::transl8::FromV8;
 use super::transl8::ToV8;
-use crate::error::value_to_type_str;
 use crate::magic::transl8::impl_magic;
 use crate::Error;
 
@@ -43,7 +42,7 @@ impl FromV8 for BigInt {
     value: v8::Local<v8::Value>,
   ) -> Result<Self, crate::Error> {
     let v8bigint = v8::Local::<v8::BigInt>::try_from(value)
-      .map_err(|_| Error::ExpectedBigInt(value_to_type_str(value)))?;
+      .map_err(|_| Error::ExpectedBigInt(value.type_repr()))?;
     let word_count = v8bigint.word_count();
     let mut words: SmallVec<[u64; 1]> = smallvec![0u64; word_count];
     let (sign_bit, _words) = v8bigint.to_words_array(&mut words);
diff --git a/serde_v8/magic/detached_buffer.rs b/serde_v8/magic/detached_buffer.rs
index bc4b3de..6f057aa 100644
--- a/serde_v8/magic/detached_buffer.rs
+++ b/serde_v8/magic/detached_buffer.rs
@@ -8,7 +8,6 @@ use super::transl8::FromV8;
 use super::transl8::ToV8;
 use super::v8slice::to_ranged_buffer;
 use super::v8slice::V8Slice;
-use crate::error::value_to_type_str;
 use crate::magic::transl8::impl_magic;
 
 // A buffer that detaches when deserialized from JS
@@ -59,9 +58,9 @@ impl FromV8 for DetachedBuffer {
     value: v8::Local<v8::Value>,
   ) -> Result<Self, crate::Error> {
     let (b, range) = to_ranged_buffer(scope, value)
-      .map_err(|_| crate::Error::ExpectedBuffer(value_to_type_str(value)))?;
+      .map_err(|_| crate::Error::ExpectedBuffer(value.type_repr()))?;
     if !b.is_detachable() {
-      return Err(crate::Error::ExpectedDetachable(value_to_type_str(value)));
+      return Err(crate::Error::ExpectedDetachable(value.type_repr()));
     }
     let store = b.get_backing_store();
     b.detach(None); // Detach
diff --git a/serde_v8/magic/external_pointer.rs b/serde_v8/magic/external_pointer.rs
index e22e41a..325236c 100644
--- a/serde_v8/magic/external_pointer.rs
+++ b/serde_v8/magic/external_pointer.rs
@@ -2,8 +2,6 @@
 
 use std::ffi::c_void;
 
-use crate::error::value_to_type_str;
-
 use super::transl8::impl_magic;
 use super::transl8::FromV8;
 use super::transl8::ToV8;
@@ -40,7 +38,7 @@ impl FromV8 for ExternalPointer {
     } else if let Ok(external) = v8::Local::<v8::External>::try_from(value) {
       Ok(ExternalPointer(external.value()))
     } else {
-      Err(crate::Error::ExpectedExternal(value_to_type_str(value)))
+      Err(crate::Error::ExpectedExternal(value.type_repr()))
     }
   }
 }
diff --git a/serde_v8/magic/string_or_buffer.rs b/serde_v8/magic/string_or_buffer.rs
index 986f7d3..23fde9f 100644
--- a/serde_v8/magic/string_or_buffer.rs
+++ b/serde_v8/magic/string_or_buffer.rs
@@ -1,7 +1,6 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
 use super::buffer::JsBuffer;
 use super::transl8::FromV8;
-use crate::error::value_to_type_str;
 use crate::magic::transl8::impl_magic;
 use crate::Error;
 use std::ops::Deref;
@@ -44,7 +43,7 @@ impl FromV8 for StringOrBuffer {
     } else if let Ok(s) = crate::from_v8(scope, value) {
       return Ok(Self::String(s));
     }
-    Err(Error::ExpectedBuffer(value_to_type_str(value)))
+    Err(Error::ExpectedBuffer(value.type_repr()))
   }
 }
 
diff --git a/serde_v8/magic/u16string.rs b/serde_v8/magic/u16string.rs
index 04d742d..b36cd09 100644
--- a/serde_v8/magic/u16string.rs
+++ b/serde_v8/magic/u16string.rs
@@ -1,6 +1,5 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
 
-use crate::error::value_to_type_str;
 use crate::Error;
 
 use super::transl8::impl_magic;
@@ -38,7 +37,7 @@ impl FromV8 for U16String {
     value: v8::Local<v8::Value>,
   ) -> Result<Self, crate::Error> {
     let v8str = v8::Local::<v8::String>::try_from(value)
-      .map_err(|_| Error::ExpectedString(value_to_type_str(value)))?;
+      .map_err(|_| Error::ExpectedString(value.type_repr()))?;
     let len = v8str.length();
     let mut buffer = Vec::with_capacity(len);
     #[allow(clippy::uninit_vec)]
diff --git a/serde_v8/magic/v8slice.rs b/serde_v8/magic/v8slice.rs
index 9ea38c6..946103f 100644
--- a/serde_v8/magic/v8slice.rs
+++ b/serde_v8/magic/v8slice.rs
@@ -5,8 +5,6 @@ use std::ops::DerefMut;
 use std::ops::Range;
 use std::rc::Rc;
 
-use crate::error::value_to_type_str;
-
 use super::rawbytes;
 use super::transl8::FromV8;
 
@@ -128,12 +126,12 @@ impl FromV8 for V8Slice {
         if store.is_resizable_by_user_javascript() {
           Err(crate::Error::ResizableBackingStoreNotSupported)
         } else if store.is_shared() {
-          Err(crate::Error::ExpectedBuffer(value_to_type_str(value)))
+          Err(crate::Error::ExpectedBuffer(value.type_repr()))
         } else {
           Ok(V8Slice { store, range })
         }
       }
-      Err(_) => Err(crate::Error::ExpectedBuffer(value_to_type_str(value))),
+      Err(_) => Err(crate::Error::ExpectedBuffer(value.type_repr())),
     }
   }
 }


Test patch:
diff --git a/serde_v8/magic/bytestring.rs b/serde_v8/magic/bytestring.rs
index 3baa704..f276211 100644
--- a/serde_v8/magic/bytestring.rs
+++ b/serde_v8/magic/bytestring.rs
@@ -1,7 +1,6 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
 use super::transl8::FromV8;
 use super::transl8::ToV8;
-use crate::error::value_to_type_str;
 use crate::magic::transl8::impl_magic;
 use crate::Error;
 use smallvec::SmallVec;
@@ -50,7 +49,7 @@ impl FromV8 for ByteString {
     value: v8::Local<v8::Value>,
   ) -> Result<Self, crate::Error> {
     let v8str = v8::Local::<v8::String>::try_from(value)
-      .map_err(|_| Error::ExpectedString(value_to_type_str(value)))?;
+      .map_err(|_| Error::ExpectedString(value.type_repr()))?;
     if !v8str.contains_only_onebyte() {
       return Err(Error::ExpectedLatin1);
     }