support async function within object literal (#4424)
This commit is contained in:
50
lib/parse.js
50
lib/parse.js
@@ -1482,7 +1482,39 @@ function parse($TEXT, options) {
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (!is("punc", ":") && start.type == "name") switch (key) {
|
||||
if (is("punc", ":")) {
|
||||
next();
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start: start,
|
||||
key: key,
|
||||
value: maybe_assign(),
|
||||
end: prev(),
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (is("punc", ",") || is("punc", "}")) {
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start: start,
|
||||
key: key,
|
||||
value: _make_symbol(AST_SymbolRef, start),
|
||||
end: prev(),
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (start.type == "name") switch (key) {
|
||||
case "async":
|
||||
key = as_property_key();
|
||||
var func_start = S.token;
|
||||
var func = function_(AST_AsyncFunction);
|
||||
func.start = func_start;
|
||||
func.end = prev();
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start: start,
|
||||
key: key,
|
||||
value: func,
|
||||
end: prev(),
|
||||
}));
|
||||
continue;
|
||||
case "get":
|
||||
a.push(new AST_ObjectGetter({
|
||||
start: start,
|
||||
@@ -1499,22 +1531,8 @@ function parse($TEXT, options) {
|
||||
end: prev(),
|
||||
}));
|
||||
continue;
|
||||
default:
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start: start,
|
||||
key: key,
|
||||
value: _make_symbol(AST_SymbolRef, start),
|
||||
end: prev(),
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
expect(":");
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start: start,
|
||||
key: key,
|
||||
value: maybe_assign(),
|
||||
end: prev(),
|
||||
}));
|
||||
unexpected();
|
||||
}
|
||||
next();
|
||||
return new AST_Object({ properties: a });
|
||||
|
||||
Reference in New Issue
Block a user