1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:47:35 +00:00

LibJS: Don't treat yield after void as identifier in generator functions

This commit is contained in:
davidot 2021-12-19 02:28:18 +01:00 committed by Linus Groh
parent a1308bfc60
commit c8e80690a7
2 changed files with 15 additions and 0 deletions

View file

@ -12,3 +12,15 @@ test("basic functionality", () => {
expect(void (() => "hello friends")()).toBeUndefined();
expect((() => void "hello friends")()).toBeUndefined();
});
describe("errors", () => {
test("treats yield in generator as non variable", () => {
expect("function f() { void yield; }").toEval();
expect("async function f() { void yield; }").toEval();
expect("function *f() { void yield; }").not.toEval();
expect("async function *f() { void yield; }").not.toEval();
expect("class C { *f() { void yield; } }").not.toEval();
expect("var obj = { async function *f() { void yield; } }").not.toEval();
});
});