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

LibJS: Allow anonymous functions as default exports

This requires a special case with names as the default function is
supposed to have a unique name ("*default*" in our case) but when
checked should have name "default".
This commit is contained in:
davidot 2022-09-02 00:46:37 +02:00 committed by Linus Groh
parent 0fc67ffd62
commit 9f661d20f7
5 changed files with 79 additions and 19 deletions

View file

@ -27,7 +27,7 @@ enum class Associativity {
};
struct FunctionNodeParseOptions {
enum {
enum : u16 {
CheckForFunctionAndName = 1 << 0,
AllowSuperPropertyLookup = 1 << 1,
AllowSuperConstructorCall = 1 << 2,
@ -36,6 +36,7 @@ struct FunctionNodeParseOptions {
IsArrowFunction = 1 << 5,
IsGeneratorFunction = 1 << 6,
IsAsyncFunction = 1 << 7,
HasDefaultExportName = 1 << 8,
};
};
@ -55,8 +56,8 @@ public:
NonnullRefPtr<Program> parse_program(bool starts_in_strict_mode = false);
template<typename FunctionNodeType>
NonnullRefPtr<FunctionNodeType> parse_function_node(u8 parse_options = FunctionNodeParseOptions::CheckForFunctionAndName, Optional<Position> const& function_start = {});
Vector<FunctionNode::Parameter> parse_formal_parameters(int& function_length, u8 parse_options = 0);
NonnullRefPtr<FunctionNodeType> parse_function_node(u16 parse_options = FunctionNodeParseOptions::CheckForFunctionAndName, Optional<Position> const& function_start = {});
Vector<FunctionNode::Parameter> parse_formal_parameters(int& function_length, u16 parse_options = 0);
enum class AllowDuplicates {
Yes,