1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:52:07 +00:00

LibJS: Fallback to undefined if last value in eval() is empty

For something like eval(""), the VM's 'last value' is an empty value,
which we must not leak.

Fixes #6643.
This commit is contained in:
Linus Groh 2021-04-25 22:52:19 +02:00
parent 2b4c2301a9
commit 7b1ba4bd5c
2 changed files with 2 additions and 1 deletions

View file

@ -11,6 +11,7 @@ test("basic eval() functionality", () => {
test("returns value of last value-producing statement", () => {
// See https://tc39.es/ecma262/#sec-block-runtime-semantics-evaluation
expect(eval("")).toBeUndefined();
expect(eval("1;;;;;")).toBe(1);
expect(eval("1;{}")).toBe(1);
expect(eval("1;var a;")).toBe(1);