[explicit-resource-management] Dispose the stack before disposal

This CL adds the requirement of having disposed stack before
calling DisposeResources on the DisposableStack.

Bug: 42203506
Change-Id: I515a5f23e609fdd9448cebc4cd71b0176c86cf99
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6298949
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Rezvan Mahdavi Hezaveh <rezvan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#98902}
This commit is contained in:
Rezvan Mahdavi Hezaveh 2025-02-24 17:20:11 -08:00 committed by test262-merge-bot
parent 15e602780c
commit d4c93d2de1
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
// Copyright (C) 2025 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Re-entry to a disposable stack should do nothing.
includes: [compareArray.js]
features: [explicit-resource-management]
---*/
let values = [];
(function TestDisposableStackReEntry() {
let stack = new DisposableStack();
stack.use({
[Symbol.dispose]() {
values.push(42);
stack.dispose();
}
});
stack.dispose();
})();
assert.compareArray(values, [42]);