Skip to content

Using Uint8Array in webidl generates invalid binding code #34362

@simonwuelker

Description

@simonwuelker

To Reproduce:
apply

diff --git a/components/script/dom/webidls/SubtleCrypto.webidl b/components/script/dom/webidls/SubtleCrypto.webidl
index be01cebf58..414717b38b 100644
--- a/components/script/dom/webidls/SubtleCrypto.webidl
+++ b/components/script/dom/webidls/SubtleCrypto.webidl
@@ -131,6 +131,15 @@ dictionary Pbkdf2Params : Algorithm {
   required HashAlgorithmIdentifier hash;
 };
 
+// https://w3c.github.io/webcrypto/#dfn-BigInteger
+typedef Uint8Array BigInteger;
+
+// https://w3c.github.io/webcrypto/#dfn-RsaKeyGenParams
+dictionary RsaKeyGenParams : Algorithm {
+  required [EnforceRange] unsigned long modulusLength;
+  required BigInteger publicExponent;
+};
+
 // JWK
 dictionary RsaOtherPrimesInfo {
   // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms

and compile with ./mach build, then observe the following compile errors being thrown:

error[E0412]: cannot find type `Uint8Array` in this scope
  --> /home/alaska/servo/target/debug/build/script-abc7480887ad9ebb/out/Bindings/SubtleCryptoBinding.rs:73:23
   |
73 | pub type BigInteger = Uint8Array;
   |                       ^^^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
5  + use crate::dom::bindings::import::module::Uint8Array;
   |
5  + use crate::dom::bindings::import::module::jsapi::Uint8Array;
   |
5  + use js::jsapi::Uint8Array;
   |
5  + use js::typedarray::Uint8Array;
   |

error[E0433]: failed to resolve: use of undeclared crate or module `typedarray`
    --> /home/alaska/servo/target/debug/build/script-abc7480887ad9ebb/out/Bindings/SubtleCryptoBinding.rs:1401:25
     |
1401 |     pub publicExponent: typedarray::Uint8Array,
     |                         ^^^^^^^^^^ use of undeclared crate or module `typedarray`
     |
help: consider importing one of these items
     |
5    + use crate::dom::bindings::import::module::typedarray;
     |
5    + use js::typedarray;
     |

error[E0433]: failed to resolve: use of undeclared crate or module `typedarray`
    --> /home/alaska/servo/target/debug/build/script-abc7480887ad9ebb/out/Bindings/SubtleCryptoBinding.rs:1448:39
     |
1448 | ...                   match typedarray::Uint8Array::from(rval.handle().get().to_object()) {
     |                             ^^^^^^^^^^ use of undeclared crate or module `typedarray`
     |
help: consider importing one of these items
     |
5    + use crate::dom::bindings::import::module::Uint8Array;
     |
5    + use crate::dom::bindings::import::module::jsapi::Uint8Array;
     |
5    + use js::jsapi::Uint8Array;
     |
5    + use js::typedarray::Uint8Array;
     |
help: if you import `Uint8Array`, refer to it directly
     |
1448 -                                 match typedarray::Uint8Array::from(rval.handle().get().to_object()) {
1448 +                                 match Uint8Array::from(rval.handle().get().to_object()) {
     |

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions