LibJS: Remove using-declaration.js from .prettierignore
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This is the second and final commit to remove using-declaration from
.prettierignore. While there is standard formatting changes here, there
is also scoping changes for the 'using' declarations due to the
following error:

Libraries/LibJS/Tests/using-declaration.js: SyntaxError:
Using declaration cannot appear in the top level when source
type is `script` or in the bare case statement.
This commit is contained in:
Adam Patterson 2025-10-03 10:27:20 -07:00 committed by Tim Flynn
commit 120bba597d
Notes: github-actions[bot] 2025-10-09 19:52:57 +00:00
2 changed files with 33 additions and 18 deletions

View file

@ -307,9 +307,14 @@ describe("works in a bunch of scopes", () => {
}
switch (2) {
case 3:
using notDisposed = { [Symbol.dispose]() { expect().fail("not-disposed 1"); } };
case 2:
case 3: {
using notDisposed = {
[Symbol.dispose]() {
expect().fail("not-disposed 1");
},
};
}
case 2: {
expect(disposeFull).toEqual([]);
using a = pusher("a");
expect(disposeFull).toEqual([]);
@ -318,22 +323,35 @@ describe("works in a bunch of scopes", () => {
expect(disposeFull).toEqual([]);
expect(b.val).toBe("b");
expect(disposeInner).toBeFalse();
// fallthrough
case 1: {
expect(disposeFull).toEqual([]);
expect(disposeInner).toBeFalse();
using inner = { [Symbol.dispose]() { disposeInner = true; } }
expect(disposeInner).toBeFalse();
}
// fallthrough
case 1:
{
expect(disposeFull).toEqual([]);
expect(disposeInner).toBeFalse();
using inner = {
[Symbol.dispose]() {
disposeInner = true;
},
};
expect(disposeInner).toBeFalse();
}
expect(disposeInner).toBeTrue();
using c = pusher("c");
expect(c.val).toBe("c");
{
using c = pusher("c");
expect(c.val).toBe("c");
}
break;
case 0:
using notDisposed2 = { [Symbol.dispose]() { expect().fail("not-disposed 2"); } };
case 0: {
using notDisposed2 = {
[Symbol.dispose]() {
expect().fail("not-disposed 2");
},
};
}
}
expect(disposeInner).toBeTrue();