mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
LibJS: Add using declaration support, RAII like operation in js
In this patch only top level and not the more complicated for loop using statements are supported. Also, as noted in the latest meeting of tc39 async parts of the spec are not stage 3 thus not included.
This commit is contained in:
parent
2c87ff2218
commit
541637e15a
15 changed files with 861 additions and 68 deletions
14
Userland/Libraries/LibJS/Tests/modules/top-level-dispose.mjs
Normal file
14
Userland/Libraries/LibJS/Tests/modules/top-level-dispose.mjs
Normal file
|
@ -0,0 +1,14 @@
|
|||
export let passed = false;
|
||||
let failed = false;
|
||||
|
||||
if (passed)
|
||||
failed = true;
|
||||
|
||||
using a = { [Symbol.dispose]() { if (!failed) passed = true; } }
|
||||
|
||||
if (passed)
|
||||
failed = true;
|
||||
|
||||
failed = true;
|
||||
// Should trigger before
|
||||
using b = { [Symbol.dispose]() { if (!passed) failed = false; } }
|
Loading…
Add table
Add a link
Reference in a new issue