1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 17:15:08 +00:00

LibJS: Distinguish between statement and declaration

This separates matching/parsing of statements and declarations and
fixes a few edge cases where the parser would incorrectly accept a
declaration where only a statement is allowed - for example:

    if (foo) const a = 1;
    for (var bar;;) function b() {}
    while (baz) class c {}
This commit is contained in:
Linus Groh 2020-10-22 23:30:07 +01:00 committed by Andreas Kling
parent f8ae6fa713
commit 80bb62b9cc
4 changed files with 73 additions and 30 deletions

View file

@ -172,6 +172,12 @@ public:
class Declaration : public Statement {
};
class ErrorDeclaration final : public Declaration {
public:
Value execute(Interpreter&, GlobalObject&) const override { return js_undefined(); }
const char* class_name() const override { return "ErrorDeclaration"; }
};
class FunctionNode {
public:
struct Parameter {