mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:47:46 +00:00
LibJS: Correctly parse yield-from expressions
This commit implements parsing for `yield *expr`, and the multiple ways something can or can't be parsed like that. Also makes yield-from a TODO in the bytecode generator. Behold, the glory of javascript syntax: ```js // 'yield' = expression in generators. function* foo() { yield *bar; // <- Syntax error here, expression can't start with * } // 'yield' = identifier anywhere else. function foo() { yield *bar; // Perfectly fine, this is just `yield * bar` } ```
This commit is contained in:
parent
d374295a26
commit
3194177dce
5 changed files with 67 additions and 42 deletions
|
@ -12,7 +12,7 @@ describe("parsing freestanding generators", () => {
|
|||
expect(`function foo() { yield; }`).toEval();
|
||||
expect(`function foo() { yield 3; }`).not.toEval();
|
||||
});
|
||||
test.skip("yield-from expression", () => {
|
||||
test("yield-from expression", () => {
|
||||
expect(`function* foo() { yield *bar; }`).toEval();
|
||||
expect(`function* foo() { yield *(yield); }`).toEval();
|
||||
expect(`function* foo() { yield
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue