summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock4
-rw-r--r--Cargo.toml2
-rw-r--r--cli/tests/integration/run_tests.rs5
-rw-r--r--cli/tests/testdata/run/explicit_resource_management/main.out5
-rw-r--r--cli/tests/testdata/run/explicit_resource_management/main.ts21
-rw-r--r--runtime/js/99_main.js5
6 files changed, 39 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1b56cd78f..410543763 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -958,9 +958,9 @@ dependencies = [
[[package]]
name = "deno_ast"
-version = "0.29.1"
+version = "0.29.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8bb902bcaa072210ca7b2f28c391f77bb16f6ef64664331c5d928d99943303c"
+checksum = "577ec3850834c2578eb44afa9250f9a807f8497664e6e2aaae19cea0aac2fe3b"
dependencies = [
"anyhow",
"base64 0.13.1",
diff --git a/Cargo.toml b/Cargo.toml
index 402b6e507..08a112f23 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -38,7 +38,7 @@ license = "MIT"
repository = "https://github.com/denoland/deno"
[workspace.dependencies]
-deno_ast = { version = "0.29.1", features = ["transpiling"] }
+deno_ast = { version = "0.29.3", features = ["transpiling"] }
deno_core = { version = "0.211.0" }
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index be9bc554a..0a5e86b1f 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -4701,3 +4701,8 @@ console.log(returnsHi());"#,
")
.assert_exit_code(1);
}
+
+itest!(explicit_resource_management {
+ args: "run --quiet --check run/explicit_resource_management/main.ts",
+ output: "run/explicit_resource_management/main.out",
+});
diff --git a/cli/tests/testdata/run/explicit_resource_management/main.out b/cli/tests/testdata/run/explicit_resource_management/main.out
new file mode 100644
index 000000000..ff5ac4b59
--- /dev/null
+++ b/cli/tests/testdata/run/explicit_resource_management/main.out
@@ -0,0 +1,5 @@
+A
+Disposed
+B
+Async disposed
+C
diff --git a/cli/tests/testdata/run/explicit_resource_management/main.ts b/cli/tests/testdata/run/explicit_resource_management/main.ts
new file mode 100644
index 000000000..0201a51f9
--- /dev/null
+++ b/cli/tests/testdata/run/explicit_resource_management/main.ts
@@ -0,0 +1,21 @@
+class Resource {
+ [Symbol.dispose]() {
+ console.log("Disposed");
+ }
+}
+class AsyncResource {
+ async [Symbol.asyncDispose]() {
+ await new Promise((resolve) => setTimeout(resolve, 10));
+ console.log("Async disposed");
+ }
+}
+
+{
+ using resource = new Resource();
+ console.log("A");
+}
+{
+ await using resource = new AsyncResource();
+ console.log("B");
+}
+console.log("C");
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index fdd82862c..af5c1d40c 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -71,6 +71,11 @@ import {
workerRuntimeGlobalProperties,
} from "ext:runtime/98_global_scope.js";
+// deno-lint-ignore prefer-primordials
+Symbol.dispose ??= Symbol("Symbol.dispose");
+// deno-lint-ignore prefer-primordials
+Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
+
let windowIsClosing = false;
let globalThis_;