1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

chore: update dlint to v0.37.0 for GitHub Actions (#17295)

Updated third_party dlint to v0.37.0 for GitHub Actions. This PR
includes following changes:
 
* fix(prefer-primordials): Stop using array pattern assignments
* fix(prefer-primordials): Stop using global intrinsics except for
`SharedArrayBuffer`
* feat(guard-for-in): Apply new guard-for-in rule
This commit is contained in:
Kenta Moriuchi 2023-01-17 01:17:18 +09:00 committed by Bartek Iwańczuk
parent 47130f3500
commit 566e30c29d
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
29 changed files with 128 additions and 103 deletions

View file

@ -3,7 +3,8 @@
"tags": ["recommended"], "tags": ["recommended"],
"include": [ "include": [
"ban-untagged-todo", "ban-untagged-todo",
"camelcase" "camelcase",
"guard-for-in"
], ],
"exclude": [ "exclude": [
"no-invalid-triple-slash-reference" "no-invalid-triple-slash-reference"

View file

@ -26,6 +26,7 @@
MapPrototypeSet, MapPrototypeSet,
MathCeil, MathCeil,
ObjectKeys, ObjectKeys,
ObjectPrototypeHasOwnProperty,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
Promise, Promise,
SafeArrayIterator, SafeArrayIterator,
@ -167,6 +168,9 @@
const details = []; const details = [];
for (const key in post.ops) { for (const key in post.ops) {
if (!ObjectPrototypeHasOwnProperty(post.ops, key)) {
continue;
}
const preOp = pre.ops[key] ?? const preOp = pre.ops[key] ??
{ opsDispatchedAsync: 0, opsCompletedAsync: 0 }; { opsDispatchedAsync: 0, opsCompletedAsync: 0 };
const postOp = post.ops[key]; const postOp = post.ops[key];

View file

@ -34,52 +34,52 @@ const headerDict: Record<string, string> = {
}; };
// deno-lint-ignore no-explicit-any // deno-lint-ignore no-explicit-any
const headerSeq: any[] = []; const headerSeq: any[] = [];
for (const name in headerDict) { for (const [name, value] of Object.entries(headerDict)) {
headerSeq.push([name, headerDict[name]]); headerSeq.push([name, value]);
} }
Deno.test(function newHeaderWithSequence() { Deno.test(function newHeaderWithSequence() {
const headers = new Headers(headerSeq); const headers = new Headers(headerSeq);
for (const name in headerDict) { for (const [name, value] of Object.entries(headerDict)) {
assertEquals(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(value));
} }
assertEquals(headers.get("length"), null); assertEquals(headers.get("length"), null);
}); });
Deno.test(function newHeaderWithRecord() { Deno.test(function newHeaderWithRecord() {
const headers = new Headers(headerDict); const headers = new Headers(headerDict);
for (const name in headerDict) { for (const [name, value] of Object.entries(headerDict)) {
assertEquals(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(value));
} }
}); });
Deno.test(function newHeaderWithHeadersInstance() { Deno.test(function newHeaderWithHeadersInstance() {
const headers = new Headers(headerDict); const headers = new Headers(headerDict);
const headers2 = new Headers(headers); const headers2 = new Headers(headers);
for (const name in headerDict) { for (const [name, value] of Object.entries(headerDict)) {
assertEquals(headers2.get(name), String(headerDict[name])); assertEquals(headers2.get(name), String(value));
} }
}); });
Deno.test(function headerAppendSuccess() { Deno.test(function headerAppendSuccess() {
const headers = new Headers(); const headers = new Headers();
for (const name in headerDict) { for (const [name, value] of Object.entries(headerDict)) {
headers.append(name, headerDict[name]); headers.append(name, value);
assertEquals(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(value));
} }
}); });
Deno.test(function headerSetSuccess() { Deno.test(function headerSetSuccess() {
const headers = new Headers(); const headers = new Headers();
for (const name in headerDict) { for (const [name, value] of Object.entries(headerDict)) {
headers.set(name, headerDict[name]); headers.set(name, value);
assertEquals(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(value));
} }
}); });
Deno.test(function headerHasSuccess() { Deno.test(function headerHasSuccess() {
const headers = new Headers(headerDict); const headers = new Headers(headerDict);
for (const name in headerDict) { for (const name of Object.keys(headerDict)) {
assert(headers.has(name), "headers has name " + name); assert(headers.has(name), "headers has name " + name);
assert( assert(
!headers.has("nameNotInHeaders"), !headers.has("nameNotInHeaders"),
@ -90,7 +90,7 @@ Deno.test(function headerHasSuccess() {
Deno.test(function headerDeleteSuccess() { Deno.test(function headerDeleteSuccess() {
const headers = new Headers(headerDict); const headers = new Headers(headerDict);
for (const name in headerDict) { for (const name of Object.keys(headerDict)) {
assert(headers.has(name), "headers have a header: " + name); assert(headers.has(name), "headers have a header: " + name);
headers.delete(name); headers.delete(name);
assert(!headers.has(name), "headers do not have anymore a header: " + name); assert(!headers.has(name), "headers do not have anymore a header: " + name);
@ -99,8 +99,8 @@ Deno.test(function headerDeleteSuccess() {
Deno.test(function headerGetSuccess() { Deno.test(function headerGetSuccess() {
const headers = new Headers(headerDict); const headers = new Headers(headerDict);
for (const name in headerDict) { for (const [name, value] of Object.entries(headerDict)) {
assertEquals(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(value));
assertEquals(headers.get("nameNotInHeaders"), null); assertEquals(headers.get("nameNotInHeaders"), null);
} }
}); });

View file

@ -34,7 +34,7 @@
break; break;
} }
const [name, data] = message; const { 0: name, 1: data } = message;
dispatch(null, name, new Uint8Array(data)); dispatch(null, name, new Uint8Array(data));
} }

View file

@ -255,7 +255,7 @@
}, },
); );
if (matchResult) { if (matchResult) {
const [meta, responseBodyRid] = matchResult; const { 0: meta, 1: responseBodyRid } = matchResult;
let body = null; let body = null;
if (responseBodyRid !== null) { if (responseBodyRid !== null) {
body = readableStreamForRid(responseBodyRid); body = readableStreamForRid(responseBodyRid);

View file

@ -360,7 +360,7 @@
ObjectKeys(value).length > 0 || ObjectKeys(value).length > 0 ||
ObjectGetOwnPropertySymbols(value).length > 0 ObjectGetOwnPropertySymbols(value).length > 0
) { ) {
const [propString, refIndex] = inspectRawObject( const { 0: propString, 1: refIndex } = inspectRawObject(
value, value,
inspectOptions, inspectOptions,
); );
@ -847,7 +847,7 @@
displayName: "", displayName: "",
delims: ["[", "]"], delims: ["[", "]"],
entryHandler: (entry, inspectOptions) => { entryHandler: (entry, inspectOptions) => {
const [index, val] = entry; const { 0: index, 1: val } = entry;
let i = index; let i = index;
lastValidIndex = index; lastValidIndex = index;
if (!ObjectPrototypeHasOwnProperty(value, i)) { if (!ObjectPrototypeHasOwnProperty(value, i)) {
@ -940,7 +940,7 @@
displayName: "Map", displayName: "Map",
delims: ["{", "}"], delims: ["{", "}"],
entryHandler: (entry, inspectOptions) => { entryHandler: (entry, inspectOptions) => {
const [key, val] = entry; const { 0: key, 1: val } = entry;
inspectOptions.indentLevel++; inspectOptions.indentLevel++;
const inspectedValue = `${ const inspectedValue = `${
inspectValueWithQuotes(key, inspectOptions) inspectValueWithQuotes(key, inspectOptions)
@ -1100,7 +1100,7 @@
const cyan = maybeColor(colors.cyan, inspectOptions); const cyan = maybeColor(colors.cyan, inspectOptions);
const red = maybeColor(colors.red, inspectOptions); const red = maybeColor(colors.red, inspectOptions);
const [state, result] = core.getPromiseDetails(value); const { 0: state, 1: result } = core.getPromiseDetails(value);
if (state === PromiseState.Pending) { if (state === PromiseState.Pending) {
return `Promise { ${cyan("<pending>")} }`; return `Promise { ${cyan("<pending>")} }`;
@ -1363,7 +1363,7 @@
); );
} else { } else {
// Otherwise, default object formatting // Otherwise, default object formatting
let [insp, refIndex] = inspectRawObject(value, inspectOptions); let { 0: insp, 1: refIndex } = inspectRawObject(value, inspectOptions);
insp = refIndex + insp; insp = refIndex + insp;
return insp; return insp;
} }
@ -1568,17 +1568,17 @@
let g_; let g_;
let b_; let b_;
if (h < 60) { if (h < 60) {
[r_, g_, b_] = [c, x, 0]; ({ 0: r_, 1: g_, 2: b_ } = [c, x, 0]);
} else if (h < 120) { } else if (h < 120) {
[r_, g_, b_] = [x, c, 0]; ({ 0: r_, 1: g_, 2: b_ } = [x, c, 0]);
} else if (h < 180) { } else if (h < 180) {
[r_, g_, b_] = [0, c, x]; ({ 0: r_, 1: g_, 2: b_ } = [0, c, x]);
} else if (h < 240) { } else if (h < 240) {
[r_, g_, b_] = [0, x, c]; ({ 0: r_, 1: g_, 2: b_ } = [0, x, c]);
} else if (h < 300) { } else if (h < 300) {
[r_, g_, b_] = [x, 0, c]; ({ 0: r_, 1: g_, 2: b_ } = [x, 0, c]);
} else { } else {
[r_, g_, b_] = [c, 0, x]; ({ 0: r_, 1: g_, 2: b_ } = [c, 0, x]);
} }
return [ return [
MathRound((r_ + m) * 255), MathRound((r_ + m) * 255),
@ -1645,7 +1645,7 @@
} }
for (let i = 0; i < rawEntries.length; ++i) { for (let i = 0; i < rawEntries.length; ++i) {
const [key, value] = rawEntries[i]; const { 0: key, 1: value } = rawEntries[i];
if (key == "background-color") { if (key == "background-color") {
if (value != null) { if (value != null) {
css.backgroundColor = value; css.backgroundColor = value;
@ -1736,12 +1736,12 @@
ansi += `\x1b[47m`; ansi += `\x1b[47m`;
} else { } else {
if (ArrayIsArray(css.backgroundColor)) { if (ArrayIsArray(css.backgroundColor)) {
const [r, g, b] = css.backgroundColor; const { 0: r, 1: g, 2: b } = css.backgroundColor;
ansi += `\x1b[48;2;${r};${g};${b}m`; ansi += `\x1b[48;2;${r};${g};${b}m`;
} else { } else {
const parsed = parseCssColor(css.backgroundColor); const parsed = parseCssColor(css.backgroundColor);
if (parsed !== null) { if (parsed !== null) {
const [r, g, b] = parsed; const { 0: r, 1: g, 2: b } = parsed;
ansi += `\x1b[48;2;${r};${g};${b}m`; ansi += `\x1b[48;2;${r};${g};${b}m`;
} else { } else {
ansi += "\x1b[49m"; ansi += "\x1b[49m";
@ -1770,12 +1770,12 @@
ansi += `\x1b[37m`; ansi += `\x1b[37m`;
} else { } else {
if (ArrayIsArray(css.color)) { if (ArrayIsArray(css.color)) {
const [r, g, b] = css.color; const { 0: r, 1: g, 2: b } = css.color;
ansi += `\x1b[38;2;${r};${g};${b}m`; ansi += `\x1b[38;2;${r};${g};${b}m`;
} else { } else {
const parsed = parseCssColor(css.color); const parsed = parseCssColor(css.color);
if (parsed !== null) { if (parsed !== null) {
const [r, g, b] = parsed; const { 0: r, 1: g, 2: b } = parsed;
ansi += `\x1b[38;2;${r};${g};${b}m`; ansi += `\x1b[38;2;${r};${g};${b}m`;
} else { } else {
ansi += "\x1b[39m"; ansi += "\x1b[39m";
@ -1799,7 +1799,7 @@
} }
if (!colorEquals(css.textDecorationColor, prevCss.textDecorationColor)) { if (!colorEquals(css.textDecorationColor, prevCss.textDecorationColor)) {
if (css.textDecorationColor != null) { if (css.textDecorationColor != null) {
const [r, g, b] = css.textDecorationColor; const { 0: r, 1: g, 2: b } = css.textDecorationColor;
ansi += `\x1b[58;2;${r};${g};${b}m`; ansi += `\x1b[58;2;${r};${g};${b}m`;
} else { } else {
ansi += "\x1b[59m"; ansi += "\x1b[59m";
@ -2045,7 +2045,7 @@
return; return;
} }
const [first, ...rest] = args; const [first, ...rest] = new SafeArrayIterator(args);
if (typeof first === "string") { if (typeof first === "string") {
this.error( this.error(

View file

@ -305,7 +305,7 @@
const prefix = `--${boundary}\r\nContent-Disposition: form-data; name="`; const prefix = `--${boundary}\r\nContent-Disposition: form-data; name="`;
// deno-lint-ignore prefer-primordials // deno-lint-ignore prefer-primordials
for (const [name, value] of formData) { for (const { 0: name, 1: value } of formData) {
if (typeof value === "string") { if (typeof value === "string") {
ArrayPrototypePush( ArrayPrototypePush(
chunks, chunks,

View file

@ -42,6 +42,8 @@
JSONParse, JSONParse,
ObjectDefineProperties, ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
// TODO(lucacasonato): add SharedArrayBuffer to primordials
// SharedArrayBufferPrototype
TypedArrayPrototypeSlice, TypedArrayPrototypeSlice,
TypeError, TypeError,
Uint8Array, Uint8Array,
@ -185,7 +187,7 @@
* @returns {InnerBody} * @returns {InnerBody}
*/ */
clone() { clone() {
const [out1, out2] = this.stream.tee(); const { 0: out1, 1: out2 } = this.stream.tee();
this.streamOrStatic = out1; this.streamOrStatic = out1;
const second = new InnerBody(out2); const second = new InnerBody(out2);
second.source = core.deserialize(core.serialize(this.source)); second.source = core.deserialize(core.serialize(this.source));
@ -447,6 +449,7 @@
if (typeof V === "object") { if (typeof V === "object") {
if ( if (
ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) || ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) ||
// deno-lint-ignore prefer-primordials
ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V) ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V)
) { ) {
return webidl.converters["ArrayBuffer"](V, opts); return webidl.converters["ArrayBuffer"](V, opts);

View file

@ -268,7 +268,10 @@
let size = 0; let size = 0;
let alignment = 1; let alignment = 1;
for (const field of new SafeArrayIterator(type.struct)) { for (const field of new SafeArrayIterator(type.struct)) {
const [fieldSize, fieldAlign] = getTypeSizeAndAlignment(field, cache); const { 0: fieldSize, 1: fieldAlign } = getTypeSizeAndAlignment(
field,
cache,
);
alignment = MathMax(alignment, fieldAlign); alignment = MathMax(alignment, fieldAlign);
size = MathCeil(size / fieldAlign) * fieldAlign; size = MathCeil(size / fieldAlign) * fieldAlign;
size += fieldSize; size += fieldSize;
@ -319,7 +322,7 @@
"Invalid UnsafeCallback, cannot be nonblocking", "Invalid UnsafeCallback, cannot be nonblocking",
); );
} }
const [rid, pointer] = ops.op_ffi_unsafe_callback_create( const { 0: rid, 1: pointer } = ops.op_ffi_unsafe_callback_create(
definition, definition,
callback, callback,
); );
@ -362,7 +365,7 @@
symbols = {}; symbols = {};
constructor(path, symbols) { constructor(path, symbols) {
[this.#rid, this.symbols] = ops.op_ffi_load({ path, symbols }); ({ 0: this.#rid, 1: this.symbols } = ops.op_ffi_load({ path, symbols }));
for (const symbol in symbols) { for (const symbol in symbols) {
if (!ObjectPrototypeHasOwnProperty(symbols, symbol)) { if (!ObjectPrototypeHasOwnProperty(symbols, symbol)) {
continue; continue;

View file

@ -140,7 +140,7 @@
// Date header: https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.2 // Date header: https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.2
let str = `HTTP/1.1 ${status} ${statusCodes[status]}\r\nDate: ${date}\r\n`; let str = `HTTP/1.1 ${status} ${statusCodes[status]}\r\nDate: ${date}\r\n`;
for (let i = 0; i < headerList.length; ++i) { for (let i = 0; i < headerList.length; ++i) {
const [name, value] = headerList[i]; const { 0: name, 1: value } = headerList[i];
// header-field = field-name ":" OWS field-value OWS // header-field = field-name ":" OWS field-value OWS
str += `${name}: ${value}\r\n`; str += `${name}: ${value}\r\n`;
} }

View file

@ -115,7 +115,7 @@
return null; return null;
} }
const [streamRid, method, url] = nextRequest; const { 0: streamRid, 1: method, 2: url } = nextRequest;
SetPrototypeAdd(this.managedResources, streamRid); SetPrototypeAdd(this.managedResources, streamRid);
/** @type {ReadableStream<Uint8Array> | undefined} */ /** @type {ReadableStream<Uint8Array> | undefined} */

View file

@ -175,7 +175,7 @@
} }
this.#promiseId = promise[promiseIdSymbol]; this.#promiseId = promise[promiseIdSymbol];
if (this.#unref) core.unrefOp(this.#promiseId); if (this.#unref) core.unrefOp(this.#promiseId);
const [rid, localAddr, remoteAddr] = await promise; const { 0: rid, 1: localAddr, 2: remoteAddr } = await promise;
this.#promiseId = null; this.#promiseId = null;
if (this.addr.transport == "tcp") { if (this.addr.transport == "tcp") {
localAddr.transport = "tcp"; localAddr.transport = "tcp";
@ -260,21 +260,21 @@
let remoteAddr; let remoteAddr;
switch (this.addr.transport) { switch (this.addr.transport) {
case "udp": { case "udp": {
[nread, remoteAddr] = await core.opAsync( ({ 0: nread, 1: remoteAddr } = await core.opAsync(
"op_net_recv_udp", "op_net_recv_udp",
this.rid, this.rid,
buf, buf,
); ));
remoteAddr.transport = "udp"; remoteAddr.transport = "udp";
break; break;
} }
case "unixpacket": { case "unixpacket": {
let path; let path;
[nread, path] = await core.opAsync( ({ 0: nread, 1: path } = await core.opAsync(
"op_net_recv_unixpacket", "op_net_recv_unixpacket",
this.rid, this.rid,
buf, buf,
); ));
remoteAddr = { transport: "unixpacket", path }; remoteAddr = { transport: "unixpacket", path };
break; break;
} }
@ -330,7 +330,7 @@
function listen(args) { function listen(args) {
switch (args.transport ?? "tcp") { switch (args.transport ?? "tcp") {
case "tcp": { case "tcp": {
const [rid, addr] = ops.op_net_listen_tcp({ const { 0: rid, 1: addr } = ops.op_net_listen_tcp({
hostname: args.hostname ?? "0.0.0.0", hostname: args.hostname ?? "0.0.0.0",
port: args.port, port: args.port,
}, args.reusePort); }, args.reusePort);
@ -338,7 +338,7 @@
return new Listener(rid, addr); return new Listener(rid, addr);
} }
case "unix": { case "unix": {
const [rid, path] = ops.op_net_listen_unix(args.path); const { 0: rid, 1: path } = ops.op_net_listen_unix(args.path);
const addr = { const addr = {
transport: "unix", transport: "unix",
path, path,
@ -354,7 +354,7 @@
return function listenDatagram(args) { return function listenDatagram(args) {
switch (args.transport) { switch (args.transport) {
case "udp": { case "udp": {
const [rid, addr] = udpOpFn( const { 0: rid, 1: addr } = udpOpFn(
{ {
hostname: args.hostname ?? "127.0.0.1", hostname: args.hostname ?? "127.0.0.1",
port: args.port, port: args.port,
@ -365,7 +365,7 @@
return new Datagram(rid, addr); return new Datagram(rid, addr);
} }
case "unixpacket": { case "unixpacket": {
const [rid, path] = unixOpFn(args.path); const { 0: rid, 1: path } = unixOpFn(args.path);
const addr = { const addr = {
transport: "unixpacket", transport: "unixpacket",
path, path,
@ -381,7 +381,7 @@
async function connect(args) { async function connect(args) {
switch (args.transport ?? "tcp") { switch (args.transport ?? "tcp") {
case "tcp": { case "tcp": {
const [rid, localAddr, remoteAddr] = await core.opAsync( const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
"op_net_connect_tcp", "op_net_connect_tcp",
{ {
hostname: args.hostname ?? "127.0.0.1", hostname: args.hostname ?? "127.0.0.1",
@ -393,7 +393,7 @@
return new TcpConn(rid, remoteAddr, localAddr); return new TcpConn(rid, remoteAddr, localAddr);
} }
case "unix": { case "unix": {
const [rid, localAddr, remoteAddr] = await core.opAsync( const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
"op_net_connect_unix", "op_net_connect_unix",
args.path, args.path,
); );

View file

@ -34,7 +34,7 @@
if (transport !== "tcp") { if (transport !== "tcp") {
throw new TypeError(`Unsupported transport: '${transport}'`); throw new TypeError(`Unsupported transport: '${transport}'`);
} }
const [rid, localAddr, remoteAddr] = await core.opAsync( const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
"op_net_connect_tls", "op_net_connect_tls",
{ hostname, port }, { hostname, port },
{ certFile, caCerts, certChain, privateKey, alpnProtocols }, { certFile, caCerts, certChain, privateKey, alpnProtocols },
@ -46,7 +46,7 @@
class TlsListener extends Listener { class TlsListener extends Listener {
async accept() { async accept() {
const [rid, localAddr, remoteAddr] = await core.opAsync( const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
"op_net_accept_tls", "op_net_accept_tls",
this.rid, this.rid,
); );
@ -70,7 +70,7 @@
if (transport !== "tcp") { if (transport !== "tcp") {
throw new TypeError(`Unsupported transport: '${transport}'`); throw new TypeError(`Unsupported transport: '${transport}'`);
} }
const [rid, localAddr] = ops.op_net_listen_tls( const { 0: rid, 1: localAddr } = ops.op_net_listen_tls(
{ hostname, port }, { hostname, port },
{ cert, certFile, key, keyFile, alpnProtocols, reusePort }, { cert, certFile, key, keyFile, alpnProtocols, reusePort },
); );
@ -86,7 +86,7 @@
alpnProtocols = undefined, alpnProtocols = undefined,
} = {}, } = {},
) { ) {
const [rid, localAddr, remoteAddr] = await opStartTls({ const { 0: rid, 1: localAddr, 2: remoteAddr } = await opStartTls({
rid: conn.rid, rid: conn.rid,
hostname, hostname,
certFile, certFile,

View file

@ -367,16 +367,16 @@
} }
#updateComponents() { #updateComponents() {
[ ({
this.#schemeEnd, 0: this.#schemeEnd,
this.#usernameEnd, 1: this.#usernameEnd,
this.#hostStart, 2: this.#hostStart,
this.#hostEnd, 3: this.#hostEnd,
this.#port, 4: this.#port,
this.#pathStart, 5: this.#pathStart,
this.#queryStart, 6: this.#queryStart,
this.#fragmentStart, 7: this.#fragmentStart,
] = componentsBuf; } = componentsBuf);
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {

View file

@ -155,7 +155,7 @@
return false; return false;
} }
const [values] = res; const values = res[0];
const keys = ObjectKeys(values); const keys = ObjectKeys(values);
for (let i = 0; i < keys.length; ++i) { for (let i = 0; i < keys.length; ++i) {
@ -196,7 +196,7 @@
return null; return null;
} }
const [values, inputs] = res; const { 0: values, 1: inputs } = res;
if (inputs[1] === null) { if (inputs[1] === null) {
inputs.pop(); inputs.pop();
} }

View file

@ -193,7 +193,7 @@
DATA_CLONE_ERR, DATA_CLONE_ERR,
}); });
for (let i = 0; i < entries.length; ++i) { for (let i = 0; i < entries.length; ++i) {
const [key, value] = entries[i]; const { 0: key, 1: value } = entries[i];
const desc = { value, enumerable: true }; const desc = { value, enumerable: true };
ObjectDefineProperty(DOMException, key, desc); ObjectDefineProperty(DOMException, key, desc);
ObjectDefineProperty(DOMException.prototype, key, desc); ObjectDefineProperty(DOMException.prototype, key, desc);

View file

@ -23,6 +23,7 @@
BigInt64ArrayPrototype, BigInt64ArrayPrototype,
BigUint64ArrayPrototype, BigUint64ArrayPrototype,
DataView, DataView,
FinalizationRegistry,
Int8ArrayPrototype, Int8ArrayPrototype,
Int16ArrayPrototype, Int16ArrayPrototype,
Int32ArrayPrototype, Int32ArrayPrototype,
@ -45,7 +46,8 @@
RangeError, RangeError,
ReflectHas, ReflectHas,
SafePromiseAll, SafePromiseAll,
SharedArrayBuffer, // TODO(lucacasonato): add SharedArrayBuffer to primordials
// SharedArrayBufferPrototype
Symbol, Symbol,
SymbolAsyncIterator, SymbolAsyncIterator,
SymbolFor, SymbolFor,
@ -205,6 +207,7 @@
assert(typeof O === "object"); assert(typeof O === "object");
assert( assert(
ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, O) || ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, O) ||
// deno-lint-ignore prefer-primordials
ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, O), ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, O),
); );
if (isDetachedBuffer(O)) { if (isDetachedBuffer(O)) {

View file

@ -18,6 +18,8 @@
const { const {
PromiseReject, PromiseReject,
PromiseResolve, PromiseResolve,
// TODO(lucacasonato): add SharedArrayBuffer to primordials
// SharedArrayBufferPrototype
StringPrototypeCharCodeAt, StringPrototypeCharCodeAt,
StringPrototypeSlice, StringPrototypeSlice,
TypedArrayPrototypeSubarray, TypedArrayPrototypeSubarray,
@ -108,6 +110,7 @@
// When doing so they will have to make sure that changes to input do not affect future calls to decode(). // When doing so they will have to make sure that changes to input do not affect future calls to decode().
if ( if (
ObjectPrototypeIsPrototypeOf( ObjectPrototypeIsPrototypeOf(
// deno-lint-ignore prefer-primordials
SharedArrayBuffer.prototype, SharedArrayBuffer.prototype,
input || input.buffer, input || input.buffer,
) )

View file

@ -23,10 +23,13 @@
AsyncGeneratorPrototypeNext, AsyncGeneratorPrototypeNext,
Date, Date,
DatePrototypeGetTime, DatePrototypeGetTime,
FinalizationRegistry,
MathMax, MathMax,
MathMin, MathMin,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest, RegExpPrototypeTest,
// TODO(lucacasonato): add SharedArrayBuffer to primordials
// SharedArrayBufferPrototype
StringPrototypeCharAt, StringPrototypeCharAt,
StringPrototypeToLowerCase, StringPrototypeToLowerCase,
StringPrototypeSlice, StringPrototypeSlice,
@ -407,6 +410,7 @@
} }
if ( if (
ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) || ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) ||
// deno-lint-ignore prefer-primordials
ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V) ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V)
) { ) {
return webidl.converters["ArrayBuffer"](V, opts); return webidl.converters["ArrayBuffer"](V, opts);

View file

@ -36,7 +36,7 @@
constructor() { constructor() {
this[webidl.brand] = webidl.brand; this[webidl.brand] = webidl.brand;
const [port1Id, port2Id] = opCreateEntangledMessagePort(); const { 0: port1Id, 1: port2Id } = opCreateEntangledMessagePort();
const port1 = createMessagePort(port1Id); const port1 = createMessagePort(port1Id);
const port2 = createMessagePort(port2Id); const port2 = createMessagePort(port2Id);
this.#port1 = port1; this.#port1 = port1;
@ -329,8 +329,7 @@
context: "Argument 2", context: "Argument 2",
}); });
const messageData = serializeJsMessageData(value, options.transfer); const messageData = serializeJsMessageData(value, options.transfer);
const [data] = deserializeJsMessageData(messageData); return deserializeJsMessageData(messageData)[0];
return data;
} }
window.__bootstrap.messagePort = { window.__bootstrap.messagePort = {

View file

@ -41,6 +41,7 @@
Uint32Array, Uint32Array,
Uint32ArrayPrototype, Uint32ArrayPrototype,
Uint8Array, Uint8Array,
WeakRef,
} = window.__bootstrap.primordials; } = window.__bootstrap.primordials;
const _rid = Symbol("[[rid]]"); const _rid = Symbol("[[rid]]");
@ -1893,7 +1894,7 @@
throw new DOMException(`${prefix}: invalid state.`, "OperationError"); throw new DOMException(`${prefix}: invalid state.`, "OperationError");
} }
for (let i = 0; i < mappedRanges.length; ++i) { for (let i = 0; i < mappedRanges.length; ++i) {
const [buffer, _rid, start] = mappedRanges[i]; const { 0: buffer, /* 1: rid, */ 2: start } = mappedRanges[i];
// TODO(lucacasonato): is this logic correct? // TODO(lucacasonato): is this logic correct?
const end = start + buffer.byteLength; const end = start + buffer.byteLength;
if ( if (
@ -1962,7 +1963,7 @@
throw new DOMException(`${prefix}: invalid state.`, "OperationError"); throw new DOMException(`${prefix}: invalid state.`, "OperationError");
} }
for (let i = 0; i < mappedRanges.length; ++i) { for (let i = 0; i < mappedRanges.length; ++i) {
const [buffer, mappedRid] = mappedRanges[i]; const { 0: buffer, 1: mappedRid } = mappedRanges[i];
const { err } = ops.op_webgpu_buffer_unmap( const { err } = ops.op_webgpu_buffer_unmap(
bufferRid, bufferRid,
mappedRid, mappedRid,

View file

@ -70,7 +70,7 @@
SetPrototypeDelete, SetPrototypeDelete,
SetPrototypeAdd, SetPrototypeAdd,
// TODO(lucacasonato): add SharedArrayBuffer to primordials // TODO(lucacasonato): add SharedArrayBuffer to primordials
// SharedArrayBuffer, // SharedArrayBufferPrototype
String, String,
StringFromCodePoint, StringFromCodePoint,
StringPrototypeCharCodeAt, StringPrototypeCharCodeAt,
@ -447,6 +447,7 @@
} }
function isSharedArrayBuffer(V) { function isSharedArrayBuffer(V) {
// deno-lint-ignore prefer-primordials
return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V); return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V);
} }

View file

@ -32,6 +32,8 @@
PromisePrototypeThen, PromisePrototypeThen,
RegExpPrototypeTest, RegExpPrototypeTest,
Set, Set,
// TODO(lucacasonato): add SharedArrayBuffer to primordials
// SharedArrayBufferPrototype
StringPrototypeEndsWith, StringPrototypeEndsWith,
StringPrototypeToLowerCase, StringPrototypeToLowerCase,
Symbol, Symbol,
@ -58,9 +60,9 @@
return webidl.converters["Blob"](V, opts); return webidl.converters["Blob"](V, opts);
} }
if (typeof V === "object") { if (typeof V === "object") {
// TODO(littledivy): use primordial for SharedArrayBuffer
if ( if (
ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) || ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) ||
// deno-lint-ignore prefer-primordials
ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V) ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V)
) { ) {
return webidl.converters["ArrayBuffer"](V, opts); return webidl.converters["ArrayBuffer"](V, opts);

View file

@ -13,7 +13,11 @@
}; };
function setBuildInfo(target) { function setBuildInfo(target) {
const [arch, vendor, os, env] = StringPrototypeSplit(target, "-", 4); const { 0: arch, 1: vendor, 2: os, 3: env } = StringPrototypeSplit(
target,
"-",
4,
);
build.target = target; build.target = target;
build.arch = arch; build.arch = arch;
build.vendor = vendor; build.vendor = vendor;

View file

@ -139,7 +139,7 @@
#pollControl = async () => { #pollControl = async () => {
while (this.#status === "RUNNING") { while (this.#status === "RUNNING") {
const [type, data] = await hostRecvCtrl(this.#id); const { 0: type, 1: data } = await hostRecvCtrl(this.#id);
// If terminate was called then we ignore all messages // If terminate was called then we ignore all messages
if (this.#status === "TERMINATED") { if (this.#status === "TERMINATED") {

View file

@ -213,7 +213,7 @@
'const unix = Deno.build.os === "darwin" || Deno.build.os === "linux"; return {'; 'const unix = Deno.build.os === "darwin" || Deno.build.os === "linux"; return {';
const typeEntries = ObjectEntries(types); const typeEntries = ObjectEntries(types);
for (let i = 0; i < typeEntries.length; ++i) { for (let i = 0; i < typeEntries.length; ++i) {
let [name, type] = typeEntries[i]; let { 0: name, 1: type } = typeEntries[i];
const optional = type.startsWith("?"); const optional = type.startsWith("?");
if (optional) type = type.slice(1); if (optional) type = type.slice(1);
@ -243,7 +243,7 @@
return [new Function("view", str), new Uint32Array(offset)]; return [new Function("view", str), new Uint32Array(offset)];
} }
const [statStruct, statBuf] = createByteStruct({ const { 0: statStruct, 1: statBuf } = createByteStruct({
isFile: "bool", isFile: "bool",
isDirectory: "bool", isDirectory: "bool",
isSymlink: "bool", isSymlink: "bool",
@ -392,8 +392,8 @@
atime, atime,
mtime, mtime,
) { ) {
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
ops.op_futime_sync(rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec); ops.op_futime_sync(rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec);
} }
@ -402,8 +402,8 @@
atime, atime,
mtime, mtime,
) { ) {
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
await core.opAsync( await core.opAsync(
"op_futime_async", "op_futime_async",
rid, rid,
@ -419,8 +419,8 @@
atime, atime,
mtime, mtime,
) { ) {
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
ops.op_utime_sync( ops.op_utime_sync(
pathFromURL(path), pathFromURL(path),
atimeSec, atimeSec,
@ -435,8 +435,8 @@
atime, atime,
mtime, mtime,
) { ) {
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
await core.opAsync( await core.opAsync(
"op_utime_async", "op_utime_async",
pathFromURL(path), pathFromURL(path),

View file

@ -172,7 +172,7 @@
); );
} }
const [status, stdout, stderr] = await SafePromiseAll([ const { 0: status, 1: stdout, 2: stderr } = await SafePromiseAll([
this.#status, this.#status,
collectOutput(this.#stdout), collectOutput(this.#stdout),
collectOutput(this.#stderr), collectOutput(this.#stderr),

@ -1 +1 @@
Subproject commit 3e5b0cea163cc0f2b3b0c7cedffc112cc49d6a78 Subproject commit 17e31cec93aef7d014dcc46bc58ef1a86c0a9995

View file

@ -285,7 +285,7 @@ function assertAllExpectationsHaveTests(
const missingTests: string[] = []; const missingTests: string[] = [];
function walk(parentExpectation: Expectation, parent: string) { function walk(parentExpectation: Expectation, parent: string) {
for (const key in parentExpectation) { for (const [key, expectation] of Object.entries(parentExpectation)) {
const path = `${parent}/${key}`; const path = `${parent}/${key}`;
if ( if (
filter && filter &&
@ -293,7 +293,6 @@ function assertAllExpectationsHaveTests(
) { ) {
continue; continue;
} }
const expectation = parentExpectation[key];
if (typeof expectation == "boolean" || Array.isArray(expectation)) { if (typeof expectation == "boolean" || Array.isArray(expectation)) {
if (!tests.has(path)) { if (!tests.has(path)) {
missingTests.push(path); missingTests.push(path);
@ -368,8 +367,8 @@ async function update() {
const currentExpectation = getExpectation(); const currentExpectation = getExpectation();
for (const path in resultTests) { for (const result of Object.values(resultTests)) {
const { passed, failed, testSucceeded } = resultTests[path]; const { passed, failed, testSucceeded } = result;
let finalExpectation: boolean | string[]; let finalExpectation: boolean | string[];
if (failed.length == 0 && testSucceeded) { if (failed.length == 0 && testSucceeded) {
finalExpectation = true; finalExpectation = true;
@ -655,9 +654,7 @@ function discoverTestsToRun(
parentExpectation: Expectation | string[] | boolean, parentExpectation: Expectation | string[] | boolean,
prefix: string, prefix: string,
) { ) {
for (const key in parentFolder) { for (const [key, entry] of Object.entries(parentFolder)) {
const entry = parentFolder[key];
if (Array.isArray(entry)) { if (Array.isArray(entry)) {
for ( for (
const [path, options] of entry.slice( const [path, options] of entry.slice(