mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
LibJS: Invalidate cached environment coordinate after delete in global
Fixes the bug in interpreter when cached environment coordinate is not invalidated after `delete` operator usage on global `this`.
This commit is contained in:
parent
9d4dfc1061
commit
331f6a9e60
3 changed files with 20 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
a = 1;
|
||||
b = 42;
|
||||
|
||||
test("basic functionality", () => {
|
||||
expect(delete a).toBeTrue();
|
||||
|
@ -7,3 +8,16 @@ test("basic functionality", () => {
|
|||
a;
|
||||
}).toThrowWithMessage(ReferenceError, "'a' is not defined");
|
||||
});
|
||||
|
||||
test("delete global var after usage", () => {
|
||||
let errors = 0;
|
||||
for (let i = 0; i < 3; ++i) {
|
||||
try {
|
||||
b++;
|
||||
} catch {
|
||||
++errors;
|
||||
}
|
||||
delete globalThis.b;
|
||||
}
|
||||
expect(errors).toBe(2);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue