Well, you are correct that that parses. But how? I'm with it right up to around "new class extends"; `new` I'm okay with, but doesn't `new` require a symbol (the name of the type to allocate) after it? I tried parsing "class extends async function" as an expression that boiled down to a type that we could new, but I get lost at "class extends" — don't we need a class name there? (Also, I didn't think `class` could be used in an expression…)
Here it is with line breaks and as many extra legal parens as I can add without redundancy, showing all the unary and binary operators involved:
return (
yield (
delete (
void (
await (
(null) in (
(this) instanceof (
typeof (
new (
class extends (
async function () {}
) {}
)()
)
)
)
)
)
)
)
)
`class extends X {}` is an anonymous class extending X. Syntactically, X is an arbitrary expression, which `async function () {}` is. At runtime, X must be a constructor on pain of TypeError, and an async function isn’t; this could be considered grounds for disqualification, as under no circumstances will it execute without exceptions.
`new` does not require an identifier or path to follow it: it can be an expression. So `new (foo)` is fine. It’s just kinda greedy as regards an open paren of a function call: `new foo.bar(baz)(quux)` is equivalent to `(new (foo.bar)(baz))(quux)` rather than any alternative grouping. Remember also that `new foo` is legal, and equivalent to `new foo()`.
Does it mean that you're creating an anonymous new class that inherits from an anonymous async function, since it's really prototype objects all the way down in JS?